Skip to content

Instantly share code, notes, and snippets.

@tejastank
Last active December 3, 2019 09:25
Show Gist options
  • Save tejastank/e87e3e78cddc4647199f6a489406b806 to your computer and use it in GitHub Desktop.
Save tejastank/e87e3e78cddc4647199f6a489406b806 to your computer and use it in GitHub Desktop.
NGINX Odoo Virtualhost Setup
upstream odooe{
server 127.0.0.1:8069;
}
upstream olongpolling {
server 127.0.0.1:8072;
}
server {
# listen 80 default_server;
add_header 'Access-Control-Allow-Origin' '*';
server_name xxx-snippetbucket.com www.xxx-snippetbucket.com;
return 302 https://$server_name$request_uri;
}
# map $proxy_add_x_forwarded_for $client_ip { "~(([0-9]{1,3}\.){3}[0-9]{1,3}),.*" $1; }
server {
listen 443;
add_header 'Access-Control-Allow-Origin' '*';
server_name www.xxx-snippetbucket.com;
ssl on;
ssl_certificate /etc/nginx/alicert.crt;
#ssl_certificate_key /etc/nginx/cert.key;
ssl_certificate_key /etc/nginx/ali.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
proxy_read_timeout 15000s;
proxy_connect_timeout 15000s;
proxy_send_timeout 15000s;
# Add Headers for odooe proxy mode
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;
# common gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
location / {
include /etc/nginx/proxy_params;
proxy_pass http://odooe;
}
location /olongpolling {
proxy_pass http://olongpolling;
}
proxy_cache cache;
proxy_cache_lock on;
proxy_cache_valid 200 7d;
proxy_cache_key "$scheme://$host$request_uri";
proxy_cache_use_stale updating;
proxy_max_temp_file_size 1M;
proxy_buffering on;
############----Caching Blocks----------------------------#################################
location ~* /web/image/ {
expires 15d;
proxy_hide_header 'Cache-Control';
proxy_hide_header 'Set-Cookie';
add_header "Cache-Control" "max-age=31536000, public";
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
access_log /var/log/nginx/microcache.log custom;
proxy_pass http://odooe;
}
location ~* /web/content/ {
expires 15d;
proxy_hide_header 'Cache-Control';
proxy_hide_header 'Set-Cookie';
add_header "Cache-Control" "max-age=31536000, public";
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
access_log /var/log/nginx/microcache.log custom;
proxy_pass http://odooe;
}
location ~* /.*/static/ {
expires 15d;
proxy_hide_header 'Cache-Control';
proxy_hide_header 'Set-Cookie';
add_header "Cache-Control" "max-age=31536000, public";
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
access_log /var/log/nginx/microcache.log custom;
proxy_pass http://odooe;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment