提问: nginx 配置根据 url 转发端口 404

2019-10-21 21:02:03 +08:00
 BigDogWang

配置如下:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location /api/ {
        proxy_pass          http://172.23.0.1:8080/;
    }

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

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

但是如果直接转发到外网比如 百度,就可以

2404 次点击
所在节点    问与答
2 条回复
ge2009
2019-10-22 18:09:20 +08:00
可以对下你的 access.log
BigDogWang
2019-10-29 17:10:07 +08:00
@ge2009 我发现我可能只是请求的太快了,容器起来以后服务器是还没真正跑起来,所以 404 了。搞了个大乌龙

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/611523

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX