[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 templates and usefull files
|
||||||
COPY odoo.conf /etc/nginx/templates/
|
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 templates and usefull files
|
||||||
COPY odoo.conf.dev /etc/nginx/templates/odoo.conf
|
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 {
|
upstream ${SERVICE}server {
|
||||||
server ${ODOO_SERVICE}:8069 fail_timeout=300s;
|
server ${SERVICE}:8069 fail_timeout=300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream ${ODOO_SERVICE}longpoll {
|
upstream ${SERVICE}longpoll {
|
||||||
server ${ODOO_SERVICE}:8072 fail_timeout=300s;
|
server ${SERVICE}:8072 fail_timeout=300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen ${NGINX_PORT};
|
listen ${NGINX_PORT};
|
||||||
server_name ${ODOO_SERVER_NAMES};
|
server_name ${SERVER_NAMES};
|
||||||
return 301 https://${DOLLSIGN}host:${NGINX_SSL_PORT}${DOLLSIGN}request_uri;
|
return 301 https://${DOLLSIGN}host:${NGINX_SSL_PORT}${DOLLSIGN}request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen ${NGINX_SSL_PORT} ssl;
|
listen ${NGINX_SSL_PORT} ssl;
|
||||||
server_name ${ODOO_SERVER_NAMES};
|
server_name ${SERVER_NAMES};
|
||||||
client_max_body_size 200M;
|
client_max_body_size 200M;
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_min_length 256;
|
gzip_min_length 256;
|
||||||
@ -29,11 +29,11 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto ${DOLLSIGN}scheme;
|
proxy_set_header X-Forwarded-Proto ${DOLLSIGN}scheme;
|
||||||
proxy_set_header X-Real-IP ${DOLLSIGN}remote_addr;
|
proxy_set_header X-Real-IP ${DOLLSIGN}remote_addr;
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://${ODOO_SERVICE}server;
|
proxy_pass http://${SERVICE}server;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
# proxy_redirect http://${DOLLSIGN}http_host/ https://${DOLLSIGN}host:${DOLLSIGN}server_port/;
|
# proxy_redirect http://${DOLLSIGN}http_host/ https://${DOLLSIGN}host:${DOLLSIGN}server_port/;
|
||||||
}
|
}
|
||||||
location /longpolling {
|
location /longpolling {
|
||||||
proxy_pass http://${ODOO_SERVICE}longpoll;
|
proxy_pass http://${SERVICE}longpoll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user