NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
23.46k stars 2.72k forks source link

Intercept errors with error page not working #1593

Open Rod-O opened 3 years ago

Rod-O commented 3 years ago

Checklist

Describe the bug I have this code on Advanced tab-> Custom Nginx Configuration that accounts for SPA routes

proxy_intercept_errors on;
error_page 404 = /index.html;

This was working on 2.9.9, upgraded to latest and now I have 404

Nginx Proxy Manager Version 2.9.12

To Reproduce Steps to reproduce the behavior:

  1. use SPA routes with this code

Expected behavior Simple page reload

dodanex commented 2 years ago

I am having the same problem! @Rod-O have you figured out how to redirect to index.html for SPA apps?

Rod-O commented 2 years ago

No, I just use 2.9.9

dodanex commented 2 years ago

hei @Rod-O , I found a solution, works in v2.9.13 (now latest) also. Enter this in your Advanced Custom Nginx Configuration:

proxy_intercept_errors on;
error_page 404 /index.html;
location = /index.html {
        proxy_pass http://your-docker-service-or-internal-ip;
}

Replace the proxy_pass with your app. I don't know if this is the best solution but this is all I have working. Hope this will help you and others that have the same problem !

chaptergy commented 2 years ago

Does the issue still exist in 2.9.13?

Rod-O commented 2 years ago

@dodanex tested a workaround for 2.9.13, which means that still exists in 2.9.13

chaptergy commented 2 years ago

I've tried debugging why this error occurs for the past hour but unfortunately I was not able to find anything and have no clue what might cause this

Rod-O commented 2 years ago

what's your environment ? set a redirect on your main app page to a route like in a classic react app (not on the proxy manager) www.example.com -> www.example.com/main/section

dodanex commented 2 years ago

Also, try to deactivate Force SSL and HTTP/2 Support and try again to see if it works. I had some problems with v2.9.12 because of that, but on a different VPS I use v2.9.13 with those options activated and it works.

chaptergy commented 2 years ago

I am using a random website, currently based.cooking and proxying that. I have added the error page to be /rss.xml and am able to replicate the issue that way. However I am not finding the source of this issue. I have both force ssl and http 2 support disabled, so that can't be the issue.

In case anyone without a SPA wants to replicate this, here is my full server config block I use:

server {
  set $forward_scheme https;
  set $server         "based.cooking";
  set $port           443;

  listen 80;
  listen [::]:80;

  server_name test1.npm.local;

  access_log /data/logs/proxy-host-1_access.log proxy;
  error_log /data/logs/proxy-host-1_error.log warn;

  proxy_intercept_errors on;
  error_page 404 = /rss.xml;

  location / {
    # Proxy!
    include conf.d/include/proxy.conf;
  }
}
github-actions[bot] commented 9 months ago

Issue is now considered stale. If you want to keep it open, please comment :+1: