V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
BigDogWang
V2EX  ›  问与答

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

  •  
  •   BigDogWang · Oct 21, 2019 · 2790 views
    This topic created in 2381 days ago, the information mentioned may be changed or developed.

    配置如下:

    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;
        }
    }
    

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

    2 replies    2019-10-29 17:10:07 +08:00
    ge2009
        1
    ge2009  
       Oct 22, 2019
    可以对下你的 access.log
    BigDogWang
        2
    BigDogWang  
    OP
       Oct 29, 2019
    @ge2009 我发现我可能只是请求的太快了,容器起来以后服务器是还没真正跑起来,所以 404 了。搞了个大乌龙
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3249 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 13:40 · PVG 21:40 · LAX 06:40 · JFK 09:40
    ♥ Do have faith in what you're doing.