您好我正在使用nginx部署nodejs应用程序来提供静态文件。静态文件使用nignx提供,动态内容由nodejs提供。
所以根据位置路由我需要向两个不同的nodejs应用程序发出请求
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;
}
}
以上是我的配置文件,现在我无法提供我的index.html文件
pinging:localhost / planner.in /通过404错误
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.
是否可以单独为js和rest(css,fonts,images ....)提供静态内容
可以帮助我如何通过nginx路由index.html文件