收藏
回答

nginx部署一直404访问不通,不知道为啥日志打印出来的就是不走location配置的代理服务器?

user  nginx;
worker_processes  1;

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;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       443;
        server_name  holmes-center-front-86714-6-1323419690.sh.run.tcloudbase.com;
        index  index.html index.htm;
        error_page  404              /404.html;
        error_page  500 502 503 504  /50x.html;

        # 生产环境
        location /prod-api/ {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header REMOTE-HOST $remote_addr;
          proxy_intercept_errors on;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass https://dlnmpwnf.xx.hahsntqc.ie54110f.com;
        }

        location / {
          root /usr/share/nginx/html;
          try_files $uri $uri/ /index.html;
          index  index.html index.htm;
        }

        location = /50x.html {
            root   /usr/share/nginx/html;
        }

    }


}


nginx配置如上:

2024/01/15 06:56:51 [error] 37#37: *99 open() "/usr/share/nginx/html/prod-api/captchaImage" failed (2: No such file or directory), client: 10.40.254.165, server: localhost, request: "GET /prod-api/captchaImage HTTP/1.1", host: "holmes-center-front-86714-6-1323419690.sh.run.tcloudbase.com", referrer: "https://holmes-center-front-86714-6-1323419690.sh.run.tcloudbase.com/login?redirect=%2Findex"

不去走代理配置的location ,反而去走了/usr/share/nginx/html/prod-api/captchaImage本地路径,配置了好久没成功,问题应该出在了ngxin配置上,求解带!


回答关注问题邀请回答
收藏

1 个回答

  • 喵不拉几
    喵不拉几
    01-15

    已解决

    01-15
    有用
    回复 2
    • 山鹰
      山鹰
      03-04
      楼主怎么解决的,我也遇到了同样的问题
      03-04
      回复
    • 风.
      风.
      05-15
      楼主,求解决方案
      05-15
      回复
登录 后发表内容
问题标签