I want to run multiple subdomains on same server each connected to a different odoo instance and all instances are running on different ports. However, I can't get one of the subdomains working, here are my configuration files, I know only one of them is the subdomain and other one is proper domain, but the you can get the idea:
example1.com.conf
# Odoo servers
upstream odoo {
server 127.0.0.1:8030;
}
upstream odoochat {
server 127.0.0.1:8072;
}
# HTTP -> HTTPS
server {
listen 80;
server_name www.example1.com example1.com;
include snippets/letsencrypt.conf;
return 301 https://example1.com$request_uri;
}
# WWW -> NON WWW
server {
listen 443 ssl http2;
server_name www.example1.com;
ssl_certificate /etc/letsencrypt/live/example1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example1.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example1.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
return 301 https://example1.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example1.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Proxy headers
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;
# SSL parameters
ssl_certificate /etc/letsencrypt/live/example1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example1.com/privkey.pem
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
# log files
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Handle longpoll requests
location /longpolling {
proxy_pass http://odoochat;
}
# Handle / requests
location / {
proxy_redirect off;
proxy_pass http://odoo;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
example2.mydomain.com
# Odoo servers
upstream example2 {
server 127.0.0.1:8015;
}
upstream example2-chat {
server 127.0.0.1:8072;
}
# HTTP -> HTTPS
server {
listen 80;
server_name www.example2.mydomain.com example2.mydomain.com;
include snippets/letsencrypt.conf;
return 301 https://example2.mydomain.com$request_uri;
}
# WWW -> NON WWW
server {
listen 443 ssl http2;
server_name www.example2.mydomain.com;
ssl_certificate /etc/letsencrypt/live/example2.mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example2.mydomain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example2.mydomain.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
return 301 https://example2.mydomain.com$request_uri;
}
server {
listen 443 ssl http2;
server_name example2.mydomain.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Proxy headers
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;
# SSL parameters
ssl_certificate /etc/letsencrypt/live/example2.mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example2.mydomain.com/privkey.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
# log files
access_log /var/log/nginx/example2.access.log;
error_log /var/log/nginx/example2.error.log;
# Handle longpoll requests
location /longpolling {
proxy_pass http://example2-chat;
}
# Handle / requests
location / {
proxy_redirect off;
proxy_pass http://example2;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://example2;
}
# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
example1.com is working just fine, however, whenever I click on anything on example2.mydomain.com it will redirect me to the name to upstream so for example:
- There is a button that will take me to
example2.mydomain.com/web - Upon clicking it will take me to
example2/webinstead - If I manually input
example2.mydomain.com/webin URL it will work just fine
I have gone through documentations, articles etc but can't figure out what I am missing in the configuration? Id it odoo thing because default odoo & odoochat upstreams are working but not the custom one that I have defined.