I have that config for nginx:
server {
listen 80;
server_name myDomain;
access_log /var/log/nginx/tomcat-access.log;
error_log /var/log/nginx/tomcat-error.log;
underscores_in_headers on;
if ($host = http://myDomain){
return 302 https://$host$request_uri;
}
location / {
#include proxy_params;
#proxy_set_header Host $server_name;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8080/myApp/;
}
location /myApp/min {
alias /var/www/httpdocs/prd.myApp.old/myapp/src/main/resources/static/min/;
}
location /assets/ {
alias /var/www/httpdocs/prd.myApp.old/myapp/src/main/resources/static/assets/;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/app.myApp.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/app.myApp.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot}
MyApp deploy at tomcat9 on Ubuntu 22 with pass localhost:8080/myApp. It is Java WAR + Angular + JSP inside. My question is what header I need to use to correct connect all redirection? Because if I use "include proxy_params" I have infinity redirect error. If I use without any headers have https loop 302 on login page without any submit. If I use 3 rows proxy_set_header from code snippet I have incorrect redirect to https://myDomain/myApp////////////// and after that have redirect to 404 bcz path is corrupted instead of myDomain/login to myDomain/myApp/login.
Please explain how it works and how I can fix that.
https://www.example.com/app/, you need to set the root URL in your app configuration. – Tero Kilkanen Mar 21 '24 at 07:30