下面是我的配置,除了路由之外,我在定义的所有路由上都收到 404 well-known
,我不明白为什么。
如果我向http://example.tech/connect发出请求,我会收到 404,如果我向http://api.example.tech发出请求,我也会收到 404。
我看不出我哪里出了问题,因为这看起来应该可行!
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#REMOVE REFERENCE TO FILES THAT HAVE "server" and "location" blocks in them so we can do it all in this file …
Run Code Online (Sandbox Code Playgroud) 我有以下配置:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000; # this is where our node js app runs at
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)
哪个代理[SERVER_IP]/
,localhost:3000
以便它基本上将所有内容路由到 node js 应用程序。
然后我继续编写了另一个 nodejs 应用程序,它在 port 上运行5000
,而不是3000
:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000; # this is where our node js app runs at
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect …
Run Code Online (Sandbox Code Playgroud)