Created
October 28, 2012 16:41
-
-
Save allspiritseve/3969109 to your computer and use it in GitHub Desktop.
Nginx configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-available/sitename.com | |
server { | |
listen 443 ssl; | |
server_name *.sitename.com; | |
keepalive_timeout 70; | |
ssl on; | |
ssl_certificate /etc/ssl/certs/sitename-bundle.crt; | |
ssl_certificate_key /etc/ssl/private/sitename.key; | |
root /var/www/sitename.com/public; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log debug; | |
location ~ ^/assets/ { | |
expires max; | |
gzip_static on; | |
add_header Cache-Control public; | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_pass http://127.0.0.1:8080; | |
client_max_body_size 128m; | |
proxy_buffer_size 64k; | |
proxy_buffers 32 32k; | |
} | |
} | |
# Redirect www.sitename.com to sitename.com | |
server { | |
listen 443 ssl; | |
server_name www.sitename.com; | |
location / { | |
rewrite ^ https://sitename.com$request_uri permanent; | |
} | |
} | |
# Redirect http to https | |
server { | |
listen 80; | |
server_name *.sitename.com; | |
location / { | |
rewrite ^ https://sitename.com$request_uri permanent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment