Reverse Proxy Help
August 27, 2021 04:39PM

i have some trouble making a reverse proxy with NGINX

I need make a proxy_pass to an external web but this external web has some static files that are not reachable. I think Nginx is trying to download assets using root location instead of /dashboard.

Please, could you help me?.

My code is something like this:

server {
listen 80;
return 301$request_uri;

server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;


ssl_certificate /var/www/certs/cert.pem;
ssl_certificate_key /var/www/certs/privkey.pem;

root /var/www/html/;

index index.html index.htm index.nginx-debian.html;

location /images {
alias /var/www/html/media;

location ^~ /dashboards{
rewrite /dashboards/(.*) /$1 break;
rewrite ^/dashboards$ /dashboards/ permanent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location / {
try_files $uri $uri/ /index.html;

Regards and thanks in advance! :)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready