Welcome! Log In Create A New Profile

Advanced

Reverse Proxy Help

Posted by Yeyeniu 
Reverse Proxy Help
August 27, 2021 04:39PM
Hello!

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;
server_name myhost.com;
return 301 https://myhost.com$request_uri;
}

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

server_name myhost.com;

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;
proxy_pass https://www.externaldashboards.com;
}

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: 74
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready