在 Nginx 位置使用 proxy_pass 作为错误页面

时间:2021-05-15 18:13:58

标签: nginx nginx-reverse-proxy

我正在配置 Nginx 以服务于两个不同的位置。想法是将 localhost:3000 作为默认值提供服务,如果在该位置找不到该页面,则尝试使用其他位置作为后备。但不工作。任何帮助将不胜感激。谢谢

server {
    listen 80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name server.in;

    ssl_certificate /junk/server.crt;
    ssl_certificate_key /junk/server.key;

    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;

    index index.html;

    recursive_error_pages on;
    proxy_intercept_errors on;

    location /  {
        proxy_pass http://localhost:3000;
        error_page 404 = @fallback;
    }

    location @fallback {
        proxy_pass http://localhost:9000;
    }
}

0 个答案:

没有答案