[IMP]Nginx for Odoo : handle odoo.conf multiple hosts, server names
This commit is contained in:
parent
499e2019fc
commit
f88ed3612d
@ -6,3 +6,4 @@ ENV ODOO_SERVER_NAMES odoo
|
||||
|
||||
# Copy templates and usefull files
|
||||
COPY odoo.conf /etc/nginx/templates/
|
||||
COPY launch.sh /launch.sh
|
||||
|
@ -6,3 +6,4 @@ ENV ODOO_SERVER_NAMES odoo
|
||||
|
||||
# Copy templates and usefull files
|
||||
COPY odoo.conf.dev /etc/nginx/templates/odoo.conf
|
||||
COPY launch.sh /launch.sh
|
||||
|
28
odoo/nginx/launch.sh
Normal file
28
odoo/nginx/launch.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Needed for envsubst to replace $ in final rendering
|
||||
export DOLLSIGN=$
|
||||
|
||||
# Bash templating
|
||||
cd /etc/nginx/templates
|
||||
for tpl in * ; do
|
||||
if [ $tpl = "odoo.conf" ]; then
|
||||
echo '' > /etc/nginx/conf/$tpl
|
||||
index=0
|
||||
IFS=':' read -ra ODOO_SERVICE <<< "$ODOO_SERVICE"
|
||||
IFS=':' read -ra ODOO_SERVER_NAMES <<< "$ODOO_SERVER_NAMES"
|
||||
for service in "${ODOO_SERVICE[@]}"
|
||||
do
|
||||
SERVICE=${ODOO_SERVICE[$index]}
|
||||
SERVER_NAMES=${ODOO_SERVER_NAMES[$index]}
|
||||
export SERVICE SERVER_NAMES
|
||||
envsubst < $tpl >> /etc/nginx/conf.d/$tpl
|
||||
((index++))
|
||||
done
|
||||
else
|
||||
envsubst < $tpl > /etc/nginx/conf.d/$tpl
|
||||
fi
|
||||
done
|
||||
|
||||
# Nginx launch
|
||||
nginx
|
@ -1,20 +1,20 @@
|
||||
upstream ${ODOO_SERVICE}server {
|
||||
server ${ODOO_SERVICE}:8069 fail_timeout=300s;
|
||||
upstream ${SERVICE}server {
|
||||
server ${SERVICE}:8069 fail_timeout=300s;
|
||||
}
|
||||
|
||||
upstream ${ODOO_SERVICE}longpoll {
|
||||
server ${ODOO_SERVICE}:8072 fail_timeout=300s;
|
||||
upstream ${SERVICE}longpoll {
|
||||
server ${SERVICE}:8072 fail_timeout=300s;
|
||||
}
|
||||
|
||||
server {
|
||||
listen ${NGINX_PORT};
|
||||
server_name ${ODOO_SERVER_NAMES};
|
||||
server_name ${SERVER_NAMES};
|
||||
return 301 https://${DOLLSIGN}host:${NGINX_SSL_PORT}${DOLLSIGN}request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen ${NGINX_SSL_PORT} ssl;
|
||||
server_name ${ODOO_SERVER_NAMES};
|
||||
server_name ${SERVER_NAMES};
|
||||
client_max_body_size 200M;
|
||||
gzip on;
|
||||
gzip_min_length 256;
|
||||
@ -29,11 +29,11 @@ server {
|
||||
proxy_set_header X-Forwarded-Proto ${DOLLSIGN}scheme;
|
||||
proxy_set_header X-Real-IP ${DOLLSIGN}remote_addr;
|
||||
location / {
|
||||
proxy_pass http://${ODOO_SERVICE}server;
|
||||
proxy_pass http://${SERVICE}server;
|
||||
proxy_redirect off;
|
||||
# proxy_redirect http://${DOLLSIGN}http_host/ https://${DOLLSIGN}host:${DOLLSIGN}server_port/;
|
||||
}
|
||||
location /longpolling {
|
||||
proxy_pass http://${ODOO_SERVICE}longpoll;
|
||||
proxy_pass http://${SERVICE}longpoll;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user