Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created October 7, 2011 17:34
Show Gist options
  • Save guilherme/1270879 to your computer and use it in GitHub Desktop.
Save guilherme/1270879 to your computer and use it in GitHub Desktop.
nginx with ssl and rewrite rule
server {
listen 80;
server_name www.myapp.com myapp.com;
rewrite ^.* https://myapp.com$request_uri permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/sslchain.crt;
ssl_certificate_key /etc/ssl/certs/server.key;
rails_env production;
server_name myapp.com www.myapp.com;
root /var/www/myapp.com/current/public;
passenger_enabled on;
passenger_friendly_error_pages off;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
if ($host = 'www.myapp.com' ) {
rewrite ^/(.*)$ https://myapp.com/$1 permanent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment