79570681

Date: 2025-04-12 16:20:03
Score: 0.5
Natty:
Report link

The key is to use Nginx's proxy_pass with URL rewriting correctly, but you need to handle it differently than you've tried. The issue with your approach is that using proxy_pass http://odoo/en; creates redirect loops because Odoo keeps seeing the /en path and tries to handle it repeatedly.

Here's how to solve it properly:

server {
    listen 443 ssl http2;
    server_name www.mycompany.com;
    
    # SSL settings as you have them...
    
    location / {
        rewrite ^(.*)$ /en$1 break;
        
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        
        # Important: Use proxy_pass without path
        proxy_pass http://odoo;
    }
    
    # Additional locations for static content, etc.
    # ...rest of your config...
}

server {
    listen 443 ssl http2;
    server_name www.mycompany.it;
    
    # SSL settings as you have them...
    
    location / {
        rewrite ^(.*)$ /it$1 break;
        
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        
        proxy_pass http://odoo;
    }
    
    # Additional locations for static content, etc.
    # ...rest of your config...
}

Note that you'll need to ensure your Odoo instance is properly set up with the correct languages and base URLs in the configuration to avoid any unexpected redirects.

Reasons:
  • Blacklisted phrase (1): how to solve
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Yassin Slati