相关疑难解决方法(0)

为什么我在 nginx 反向代理上收到 404?

下面是我的配置,除了路由之外,我在定义的所有路由上都收到 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)

nginx nginx-location nginx-reverse-proxy

5
推荐指数
2
解决办法
2万
查看次数

多个 Node JS Express 应用程序的 Nginx 多个位置

我有以下配置:

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)

proxy nginx node.js nginx-location

3
推荐指数
1
解决办法
1650
查看次数