V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
yuedingwangji
V2EX  ›  NGINX

nginx A 自定义 502 状态码页面为 B 域的 URI

  •  
  •   yuedingwangji · Jan 8, 2018 · 2597 views
    This topic created in 3043 days ago, the information mentioned may be changed or developed.

    如果有个域名。www.a.com 配置如下

         error_page 502  /502.html;
        location ~ /502.html {
            rewrite  (.*)    /templates/502.html  break;
            
            proxy_pass  https://www.b.com;
    

    如果是这样配置的话, 访问的时候会报 HTTP/1.1 500 Internal Server Error 如果改成

         error_page 502  /502.html;
       location ~ /502.html {
           rewrite  (.*)    /templates/502.html  break;
           
           proxy_pass  http://www.b.com;
    

    因为 b 域做了 http 强制跳转 https, 访问的时候又会报 302 not found ; 去掉 break 的时候,访问也是报 500

    1 replies    2018-01-09 17:30:15 +08:00
    yuedingwangji
        1
    yuedingwangji  
    OP
       Jan 9, 2018
    好失望,为什么一个回复都没呀
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5354 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:19 · PVG 16:19 · LAX 01:19 · JFK 04:19
    ♥ Do have faith in what you're doing.