nginx-proxy-manager
nginx-proxy-manager copied to clipboard
Add configurable error pages
It would be nice to allow the user to specify the content for the following pages
- upstream 404
- upstream 500
- upstream unavailable error
- default page when no matching hostname is configured
default page when no matching hostname is configured
+1 to this, will be a great enhancement.
+1
Waiting for this.
+1
I would like the option to have the default page when no hostname is specified return just a 404 error message. Or just make it so that if anything is hit that is not a valid hostname proxy, it returns a 404 including if the default page is hit from the client using IP of the server in the URL
+1
Sorry if this is a dumb question, but what is currently the best work around for not exposing that page saying "Congratulations! You've successfully started the Nginx Proxy Manager"? My quick solution was to create a redirect host for my bare IP and redirect to some public website. So Whoever visits my IP will just be bounced back into the internet... :-)
It would be nice to allow the user to specify the content for the following pages
- upstream 404
- upstream 500
- upstream unavailable error
- default page when no matching hostname is configured
This feature is really needful!
@tophee Is redirection to a public site still the best solution?
@jc21 any updates or plans on this feature enhancement?
+1
Sorry if this is a dumb question, but what is currently the best work around for not exposing that page saying "Congratulations! You've successfully started the Nginx Proxy Manager"? My quick solution was to create a redirect host for my bare IP and redirect to some public website. So Whoever visits my IP will just be bounced back into the internet... :-)
Hello, I also see that Congratulations page on my external IP. Can You tell how to make that redirection? Regards.
+1 Sorry if this is a dumb question, but what is currently the best work around for not exposing that page saying "Congratulations! You've successfully started the Nginx Proxy Manager"? My quick solution was to create a redirect host for my bare IP and redirect to some public website. So Whoever visits my IP will just be bounced back into the internet... :-)
Hello, I also see that Congratulations page on my external IP. Can You tell how to make that redirection? Regards.
You should go to settings page in web UI and change Default site settings from Congratulations page to 404 page or Custom HTML or configure a redirection.
Hi, thanks for Your answer. I miss that settings tab. I thougt I have to make someting in command line :D Thanks.
Any updates? I really need this.
+1 Sorry if this is a dumb question, but what is currently the best work around for not exposing that page saying "Congratulations! You've successfully started the Nginx Proxy Manager"? My quick solution was to create a redirect host for my bare IP and redirect to some public website. So Whoever visits my IP will just be bounced back into the internet... :-)
Hello, I also see that Congratulations page on my external IP. Can You tell how to make that redirection? Regards.
You should go to settings page in web UI and change Default site settings from Congratulations page to 404 page or Custom HTML or configure a redirection.
Your talking about setting ( default setup page ); the guys asking for error page, and not default page... how to change the error pages, 502 bad gateway template or pages ?
Its good idea to add way to setup custom html error pages for HTTP error codes, for example I want to replace this
with my own.
still waiting
same here, waiting.
Hi everyone, I agree that this should be implemented in the UI but until then, I wanted to explain how I managed to do it so that you can too.
Create a directory named error_pages
under your /data/nginx/
directory. Prepare your custom error pages and put them in there. These files will be persistent as I suppose that you mount /data
directory to your host machine.
After restarting your container; visit the dashboard, edit a proxy host, go to Advanced tab and paste the following with respect to the name of your error page file:
# Error page for 50x
error_page 500 502 503 504 /error-cloud.html;
proxy_intercept_errors on;
location /error-cloud.html {
internal;
root /data/nginx/error_pages;
}
In this case, my error page filename is error-cloud.html
where HTTP code is one of 500, 502, 503 or 504.
You can prepare different error pages for different hosts and also different error pages for different response codes. Hope this is helpful.
Using HttpErrorPages with the solution of @kylethedeveloper:
location / {
# ... all other configuration
error_page 400 /error_pages/HTTP400.html;
error_page 401 /error_pages/HTTP402.html;
error_page 402 /error_pages/HTTP402.html;
error_page 403 /error_pages/HTTP403.html;
error_page 404 /error_pages/HTTP404.html;
error_page 500 /error_pages/HTTP500.html;
error_page 501 /error_pages/HTTP501.html;
error_page 502 /error_pages/HTTP502.html;
error_page 503 /error_pages/HTTP503.html;
proxy_intercept_errors on;
}
location /error_pages/ {
alias /data/nginx/error_pages/;
internal;
}
This maybe can be the default inside NPM + HttpErrorPages @jc21
You can add a file server_proxy.conf in your /data/nginx/custom with your content example to set the custom error page globaly :
error_page 400 /error_pages/HTTP400.html;
error_page 401 /error_pages/HTTP402.html;
error_page 402 /error_pages/HTTP402.html;
error_page 403 /error_pages/HTTP403.html;
error_page 404 /error_pages/HTTP404.html;
error_page 500 /error_pages/HTTP500.html;
error_page 501 /error_pages/HTTP501.html;
error_page 502 /error_pages/HTTP502.html;
error_page 503 /error_pages/HTTP503.html;
proxy_intercept_errors on;
location /error_pages/ {
alias /data/nginx/error_pages/;
internal;
}
Or comment proxy_intercept_errors on;
and just add this directive in the proxy host advanced configuration.
I've added server_proxy.conf
to /data/nginx/error_pages/
(- /data/nginx/error_pages/server_proxy.conf)
and the html pages but it isn't working! Do I still need to add the above to the advanced tab?
How do I set this globaly in NPM?
Hi everyone, I agree that this should be implemented in the UI but until then, I wanted to explain how I managed to do it so that you can too.
Create a directory named
error_pages
under your/data/nginx/
directory. Prepare your custom error pages and put them in there. These files will be persistent as I suppose that you mount/data
directory to your host machine.After restarting your container; visit the dashboard, edit a proxy host, go to Advanced tab and paste the following with respect to the name of your error page file:
# Error page for 50x error_page 500 502 503 504 /error-cloud.html; proxy_intercept_errors on; location /error-cloud.html { internal; root /data/nginx/error_pages; }
In this case, my error page filename is
error-cloud.html
where HTTP code is one of 500, 502, 503 or 504.You can prepare different error pages for different hosts and also different error pages for different response codes. Hope this is helpful.
How do you prepare different error codes for the same proxy host? e.g. If you want to have an 403 and 502 error page. And also when I add an image to my custom 502 html error page the image doesn’t show but I use the same html code for the 404 custom page and then the image shows…very weird behavior.
Is it still planned to integrate this in the future?
I've added
server_proxy.conf
to/data/nginx/error_pages/
(- /data/nginx/error_pages/server_proxy.conf)
and the html pages but it isn't working! Do I still need to add the above to the advanced tab?How do I set this globaly in NPM?
Also, for anyone having the same issue as @BobWs, the server_proxy.conf
has to be created in /data/nginx/custom
, not any other directory, such as /data/nginx/error_pages
. Only then, it is being recognized by NPM.
When I did this, I ran into another error:
nginx: [emerg] "proxy_intercept_errors" directive is duplicate in /data/nginx/custom/server_proxy.conf:10
It seems that this directive has been set somewhere else, and nginx does not accept duplicates. I could fix this by commenting out the ´proxy_intercept_errors on;´and now it is working beautifully.
Hope this helps someone.
error_page 400 /error_pages/HTTP400.html; error_page 401 /error_pages/HTTP402.html; error_page 402 /error_pages/HTTP402.html; error_page 403 /error_pages/HTTP403.html; error_page 404 /error_pages/HTTP404.html; error_page 500 /error_pages/HTTP500.html; error_page 501 /error_pages/HTTP501.html; error_page 502 /error_pages/HTTP502.html; error_page 503 /error_pages/HTTP503.html; proxy_intercept_errors on;
location /error_pages/ { alias /data/nginx/error_pages/; internal; }
I'm using this approach to handle errors and it works. Although I'd like to only show these error pages when the content-type is not an application/json because today API errors also end up returning HTML. Has anyone else encountered this and found a solution? Thank you in advance
I'm using this approach to handle errors and it works.
I was using the same approach for a general error_page handling for all my proxy hosts, but that resulted in conflict with some of my docker apps for which I was using NPM. For example Mattermost and Vaultwarden 2FA didn't work anymore when I set the error_page in the general approach, as soon as I removed this then Mattermost and Vaultwarden 2FA started working again. So now I'm using the error_page on individual base only for the apps that need a error_page to inform users.
I followed this tutorial exactly to create a custom html 403 page but even with the help of chat gpt i cant make it work . I am trying to test via proxy sites
i am using docker to keep up and running npm using the following compose
version: '3'
services:
nginx-proxy-manager:
container_name: nginx-proxy-manager
image: 'jc21/nginx-proxy-manager:latest'
restart: always
ports:
- '80:80'
- '81:81'
- '443:443'
- '2121:2121'
- '2222:2222'
environment:
- DB_MYSQL_HOST=nginx-proxy-manager-db
- DB_MYSQL_PORT=3306
- DB_MYSQL_USER=npm
- DB_MYSQL_PASSWORD=xxxxxxxxxxxxx
- DB_MYSQL_NAME=npm
volumes:
- /mnt/containers/nginx-proxy-manager/container-data/data:/data:Z
- /mnt/containers/nginx-proxy-manager/container-data/letsencrypt:/etc/letsencrypt:Z
- /mnt/containers/nginx-proxy-manager/container-data/geoip_allow_ro.conf:/etc/nginx/conf.d/geoip_allow_ro.conf:Z
networks:
- nginx-proxy-manager-nw
- reverseproxy-nw
nginx-proxy-manager-db:
container_name: nginx-proxy-manager-db
image: 'jc21/mariadb-aria:latest'
restart: always
environment:
- MYSQL_DATABASE=npm
- MYSQL_USER=npm
- MYSQL_PASSWORD=yyyyyyyyyyyyyyy
- MYSQL_ROOT_PASSWORD=zzzzzzzzzzzzzzz
volumes:
- /mnt/containers/nginx-proxy-manager/container-data/mysql:/var/lib/mysql:Z
networks:
- nginx-proxy-manager-nw
networks:
nginx-proxy-manager-nw:
reverseproxy-nw:
external: true
I created the server_proxy.conf /mnt/containers/nginx-proxy-manager/container-data/data/nginx/custom/ with the following lines
error_page 403 /error_pages/HTTP403.html;
location /error_pages/ {
alias /data/nginx/error_pages/;
internal;
}
In the /mnt/containers/nginx-proxy-manager/container-data/data/nginx/error_pages/ i created the HTTP403.html file
and in the Custom Nginx Configuration tab i have
proxy_hide_header Upgrade;
proxy_hide_header X-Powered-By;
proxy_pass_header Set-Cookie;
add_header Content-Security-Policy "upgrade-insecure-requests";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "no-transform, no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
add_header Referrer-Policy no-referrer always;
add_header X-Robots-Tag none;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
proxy_request_buffering off;
proxy_buffering off;
rewrite ^/seafhttp(.*)$ $1 break;
client_max_body_size 128M;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 36000s;
proxy_send_timeout 36000s;
proxy_read_timeout 36000s;
allow 192.168.0.0/16;
allow 10.8.0.0/24;
include /etc/nginx/conf.d/geoip_allow_ro.conf;
deny all;
I dont know whats missing, when i try to remote accees it to get the 403 error page , i just receive the classic drop
I followed this tutorial exactly to create a custom html 403 page but even with the help of chat gpt i cant make it work . I am trying to test via proxy sites
i am using docker to keep up and running npm using the following compose
version: '3' services: nginx-proxy-manager: container_name: nginx-proxy-manager image: 'jc21/nginx-proxy-manager:latest' restart: always ports: - '80:80' - '81:81' - '443:443' - '2121:2121' - '2222:2222' environment: - DB_MYSQL_HOST=nginx-proxy-manager-db - DB_MYSQL_PORT=3306 - DB_MYSQL_USER=npm - DB_MYSQL_PASSWORD=xxxxxxxxxxxxx - DB_MYSQL_NAME=npm volumes: - /mnt/containers/nginx-proxy-manager/container-data/data:/data:Z - /mnt/containers/nginx-proxy-manager/container-data/letsencrypt:/etc/letsencrypt:Z - /mnt/containers/nginx-proxy-manager/container-data/geoip_allow_ro.conf:/etc/nginx/conf.d/geoip_allow_ro.conf:Z networks: - nginx-proxy-manager-nw - reverseproxy-nw nginx-proxy-manager-db: container_name: nginx-proxy-manager-db image: 'jc21/mariadb-aria:latest' restart: always environment: - MYSQL_DATABASE=npm - MYSQL_USER=npm - MYSQL_PASSWORD=yyyyyyyyyyyyyyy - MYSQL_ROOT_PASSWORD=zzzzzzzzzzzzzzz volumes: - /mnt/containers/nginx-proxy-manager/container-data/mysql:/var/lib/mysql:Z networks: - nginx-proxy-manager-nw networks: nginx-proxy-manager-nw: reverseproxy-nw: external: true
I created the server_proxy.conf /mnt/containers/nginx-proxy-manager/container-data/data/nginx/custom/ with the following lines
error_page 403 /error_pages/HTTP403.html; location /error_pages/ { alias /data/nginx/error_pages/; internal; }
In the /mnt/containers/nginx-proxy-manager/container-data/data/nginx/error_pages/ i created the HTTP403.html file
and in the Custom Nginx Configuration tab i have
proxy_hide_header Upgrade; proxy_hide_header X-Powered-By; proxy_pass_header Set-Cookie; add_header Content-Security-Policy "upgrade-insecure-requests"; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; add_header Cache-Control "no-transform, no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires "0" always; add_header Referrer-Policy no-referrer always; add_header X-Robots-Tag none; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; proxy_request_buffering off; proxy_buffering off; rewrite ^/seafhttp(.*)$ $1 break; client_max_body_size 128M; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_connect_timeout 36000s; proxy_send_timeout 36000s; proxy_read_timeout 36000s; allow 192.168.0.0/16; allow 10.8.0.0/24; include /etc/nginx/conf.d/geoip_allow_ro.conf; deny all;
I dont know whats missing, when i try to remote accees it to get the 403 error page , i just receive the classic drop
You need to add proxy_intercept_errors on;
on server proxy.conf or advanced settings where you want that page works.
I followed this tutorial exactly to create a custom html 403 page but even with the help of chat gpt i cant make it work . I am trying to test via proxy sites
i am using docker to keep up and running npm using the following compose
version: '3' services: nginx-proxy-manager: container_name: nginx-proxy-manager image: 'jc21/nginx-proxy-manager:latest' restart: always ports: - '80:80' - '81:81' - '443:443' - '2121:2121' - '2222:2222' environment: - DB_MYSQL_HOST=nginx-proxy-manager-db - DB_MYSQL_PORT=3306 - DB_MYSQL_USER=npm - DB_MYSQL_PASSWORD=xxxxxxxxxxxxx - DB_MYSQL_NAME=npm volumes: - /mnt/containers/nginx-proxy-manager/container-data/data:/data:Z - /mnt/containers/nginx-proxy-manager/container-data/letsencrypt:/etc/letsencrypt:Z - /mnt/containers/nginx-proxy-manager/container-data/geoip_allow_ro.conf:/etc/nginx/conf.d/geoip_allow_ro.conf:Z networks: - nginx-proxy-manager-nw - reverseproxy-nw nginx-proxy-manager-db: container_name: nginx-proxy-manager-db image: 'jc21/mariadb-aria:latest' restart: always environment: - MYSQL_DATABASE=npm - MYSQL_USER=npm - MYSQL_PASSWORD=yyyyyyyyyyyyyyy - MYSQL_ROOT_PASSWORD=zzzzzzzzzzzzzzz volumes: - /mnt/containers/nginx-proxy-manager/container-data/mysql:/var/lib/mysql:Z networks: - nginx-proxy-manager-nw networks: nginx-proxy-manager-nw: reverseproxy-nw: external: true
I created the server_proxy.conf /mnt/containers/nginx-proxy-manager/container-data/data/nginx/custom/ with the following lines
error_page 403 /error_pages/HTTP403.html; location /error_pages/ { alias /data/nginx/error_pages/; internal; }
In the /mnt/containers/nginx-proxy-manager/container-data/data/nginx/error_pages/ i created the HTTP403.html file and in the Custom Nginx Configuration tab i have
proxy_hide_header Upgrade; proxy_hide_header X-Powered-By; proxy_pass_header Set-Cookie; add_header Content-Security-Policy "upgrade-insecure-requests"; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; add_header Cache-Control "no-transform, no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires "0" always; add_header Referrer-Policy no-referrer always; add_header X-Robots-Tag none; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; proxy_request_buffering off; proxy_buffering off; rewrite ^/seafhttp(.*)$ $1 break; client_max_body_size 128M; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_connect_timeout 36000s; proxy_send_timeout 36000s; proxy_read_timeout 36000s; allow 192.168.0.0/16; allow 10.8.0.0/24; include /etc/nginx/conf.d/geoip_allow_ro.conf; deny all;
I dont know whats missing, when i try to remote accees it to get the 403 error page , i just receive the classic drop
You need to add
proxy_intercept_errors on;
on server proxy.conf or advanced settings where you want that page works.
Tried in both locations : /mnt/containers/nginx-proxy-manager/container-data/data/nginx/custom/server_proxy.conf or Custom Nginx Configuration with a simplified idea of
proxy_intercept_errors on; deny all;
Still receving 403 Forbidden, what i can test more ?
Still receving 403 Forbidden, what i can test more ?
@Alex-Goaga
I can't think of what the error could be. I would recommend you try:
- Remove some of the custom configuration they have for that proxy (obviously leaving
proxy_intercept_errors enabled;
). In this way, check if there is any conflict between configurations. - Check the logs of proxy. the location inside the container are
/data/logs/proxy-host-<ID>_access.log
and/data/logs/proxy-host-<ID>_error.log
. You can find the ID, inside the files that are in/data/nginx/proxy_host
. This directory contains the final configuration files for each proxy that are generated from the administrator UI.
@Alex-Goaga Have you check the permissions of the folders and error_pages you created if they are set right?