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! :)