How to deploy nodejs, angularjs and apache
I am currently working on the seed project
I want to use
nodejs
like api server
listening on a port 5001
,
express
as a basic structure,
angularjs
as a front-end framework,
and apache
how static file server
(like many .js files that require angular) listening on port5000
In angular I have below config
app.config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}]);
As for apache, I add the following config to /etc/apache2/sites-available/000-default.conf
Listen 5000
<VirtualHost *:5000>
DocumentRoot /var/www/seed/public
<Directory /var/www/seed/public >
AllowOverride All
</Directory>
</VirtualHost>
I also add the /public/.htaccess
file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# support angular
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /#!/$1
</IfModule>
Current rewrite rule for angular because it needs a hash band when the user refreshes the page
Now I dont know how to redirect api request with url starting with /api
to port5001
Can it be done with a file .htaccess
?
And is there a better way to collaborate with nodejs, angularjs and apache?
I couldn't find any tutorial about this combination ...
Thanks for reading or answering my question.
source to share
No one has answered this question yet
Check out similar questions: