Created
December 14, 2024 15:34
-
-
Save repodevs/0e809d2de299b6d30720a5e1ae80aa39 to your computer and use it in GitHub Desktop.
Odoo 16 multi server inside Load Balancer and proxy nginx config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## [public internet] -> [Load Balancer: e.g Alicloud SLB, AWS ELB, etc] -> [nginx proxy] -> [odoo service] | |
#odoo server | |
upstream odoo { | |
least_conn; | |
server 127.0.0.1:8079; | |
server 172.16.116.10:8079; # server prod 2 | |
# server 172.16.116.10:8079 down; # exclude from load balance | |
# add more server here | |
} | |
upstream odoochat { | |
server 127.0.0.1:8072; | |
# server 172.16.116.10:8072; # server prod 2 | |
} | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
# http -> https | |
# server { | |
# listen 8045; | |
# server_name erp.yourdoumain.id; | |
# rewrite ^(.*) https://$host$1 permanent; | |
# } | |
# http only | |
server { | |
listen 8045; | |
# server_name erp.yourdoumain.id; | |
# server_name _; | |
proxy_read_timeout 720s; | |
proxy_connect_timeout 720s; | |
proxy_send_timeout 720s; | |
# SSL parameters | |
# ssl_certificate /etc/ssl/nginx/server.crt; | |
# ssl_certificate_key /etc/ssl/nginx/server.key; | |
# ssl_session_timeout 30m; | |
# ssl_protocols TLSv1.2; | |
# ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; | |
# ssl_prefer_server_ciphers off; | |
# log | |
access_log /var/log/nginx/odoo.access.log; | |
error_log /var/log/nginx/odoo.error.log; | |
# Redirect websocket requests to odoo gevent port | |
location /websocket { | |
proxy_pass http://odoochat; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
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; | |
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; | |
# proxy_cookie_flags session_id samesite=lax secure; # requires nginx 1.19.8 | |
} | |
# Redirect requests to odoo backend server | |
location / { | |
# Add Headers for odoo proxy mode | |
# proxy_set_header X-Forwarded-Host $host; # original | |
## hack inside https://github.com/pallets-eco/flask-wtf/issues/223#issuecomment-255571989 | |
proxy_set_header X-Forwarded-Host $host:$server_port; | |
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_redirect off; | |
proxy_pass http://odoo; | |
} | |
# file upload body size | |
client_max_body_size 100M; | |
# common gzip | |
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript; | |
gzip on; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment