Skip to content

Instantly share code, notes, and snippets.

@jverweijL
Last active May 9, 2018 04:34
Show Gist options
  • Save jverweijL/44d6b96aa1830e1561fba138f64c8d34 to your computer and use it in GitHub Desktop.
Save jverweijL/44d6b96aa1830e1561fba138f64c8d34 to your computer and use it in GitHub Desktop.

caching.conf

proxy_cache_path /var/cache/nginx/liferay_cache levels=1:2 keys_zone=liferay_cache:10m inactive=60m max_size=256M;

default.conf

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location /static {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

liferay.bluemonkey.io

upstream liferay_upstream {

    server 127.0.0.1:8080 fail_timeout=3m weight=2000000000;
    #server 10.0.0.4:8080 fail_timeout=3m weight=1;

    ip_hash;
}

server {
    listen        443 backlog=4096;
    server_name    liferay.bluemonkey.io;
    client_max_body_size 50M;
    #access_log    /opt/www/sites/liferay.bluemonkey.io/logs/access.log main_timed;
    
    # See https://mozilla.github.io/server-side-tls/ssl-config-generator/ for appropriate SSL settings
    ssl                 on;
ssl_certificate /etc/letsencrypt/live/liferay.bluemonkey.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/liferay.bluemonkey.io/privkey.pem; # managed by Certbot
    add_header          Strict-Transport-Security max-age=15768000;
        
    location / {
        proxy_pass              http://liferay_upstream;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        Host $host;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_read_timeout      180s;
        proxy_connect_timeout    10s;
        proxy_redirect          http:// https://;
        proxy_next_upstream     error timeout invalid_header http_502 http_503 http_504;
        add_header              X-Cached $upstream_cache_status;
        proxy_cache_use_stale   off;
        proxy_cache             liferay_cache;
        gzip_comp_level         3;
        gzip_proxied            any;
        gzip_types              text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    }
}

server {
    listen          80 backlog=4096;
    server_name     liferay.bluemonkey.io;
    
    rewrite         ^ https://$server_name$request_uri? redirect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment