Hi i am using nginx to deploy nodejs application to serve static files.static files are served using nignx and dynamic contents are served by nodejs .
so based on the location routing i need to give request to two different nodejs application
server {
listen 80;
server_name localhost;
location /planner.in/ {
proxy_pass http://localhost:3000;
access_log planner;
}
location ~* ^(planner.in).*.+\.(js)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:8181;
proxy_redirect off;
}
location ~* ^(planner.in).*.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|flv|swf|woff|eot|ttf|svg|html|htm)$ {
proxy_pass http://localhost:8182;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8181;
server_name localhost;
location /planner.in/ {
root www/planner/public/;
index index.html;
access_log planner_js;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8182;
server_name localhost;
location /planner.in/ {
root www/planner/public/;
access_log planner_others;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
The above is my configuration file now i cannot serve my index.html file
pinging: localhost/planner.in/ through 404 error
location /planner/{} should route index.html
location /planner/api/ {} should route node dynamic content
location ~* ^(labs.in).*.+\.(js)$ {} should route only js file
location ~* ^(labs.in).*.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|flv|swf|woff|eot|ttf|svg|html|htm)$ {} should route only extension mentioned above.
Is it possible to serve static content separately for js and rest(css,fonts,images....)
can any help me how can i route index.html file through nginx