Skip to content

Instantly share code, notes, and snippets.

@iledarn
Last active March 19, 2017 15:40
Show Gist options
  • Save iledarn/7b01777c4b12c447f6aa0fd3465192b3 to your computer and use it in GitHub Desktop.
Save iledarn/7b01777c4b12c447f6aa0fd3465192b3 to your computer and use it in GitHub Desktop.
upstream app_server {
   server 127.0.0.1:8069 fail_timeout=0;
}

server {
   listen 80;
   listen [::]:80 default ipv6only=on;
   add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
   rewrite ^(.*) https://$host$1 permanent;
}

server{

   access_log /var/log/nginx/odoo-access.log;
   error_log /var/log/nginx/odoo-error.log;

   listen 443 ssl default deferred;
   ssl_dhparam /etc/nginx/ssl/dhparam.pem;
   ssl_certificate /etc/nginx/ssl/nginx.crt;
   ssl_certificate_key /etc/nginx/ssl/nginx.key;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   location / {
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Host $http_host;
       proxy_redirect off;
       proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

       if (!-f $request_filename) {
           proxy_pass http://app_server;
           break;
       }
   }

   add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

   location ~* /web/static/ {
       proxy_cache_valid 200 60m;
       proxy_buffering on;
       expires 864000;
       proxy_pass http://app_server;
   }
}
@yelizariev
Copy link

location for static could be

 location ~* /[^/]*/static/ {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment