2
在下面的代碼中,我通過nginx重定向到http://127.0.0.1:3000/app1/namelist/name=xyz
。當我點擊http://127.0.0.1:80/
時,它會拋出一個錯誤「Can not GET /」。我該如何解決這個問題?Nginx配置
如果我直接點擊127.0.0.1:3000/app1/namelist/name=xyz
,它應該通過nginx重定向。可以在nginx中配置嗎?
#user nobody; worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream node_entry {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name 127.0.0.1;
location/{
#root html;
#index index.html index.htm;
#return 503;
proxy_pass http://node_entry/;
}
}
}
你說'/ app1/namelist'而上游只說'127.0.0.1:3000' –
你能否澄清一下:是/ 80 /需要點擊:3000/app1/namelist/name = xyz?代理傳遞將發送路徑到上游。 /仍然是/在端口3000上。 – developer