Skip to content

Instantly share code, notes, and snippets.

@JSeam2
Created September 14, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JSeam2/8871a640288a07688944c8a114fdd197 to your computer and use it in GitHub Desktop.
Save JSeam2/8871a640288a07688944c8a114fdd197 to your computer and use it in GitHub Desktop.
Example Nginx Conf to redirect http to https
# Redirect to HTTPS
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
server_name example.com www.example.com;
ssl on;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert_key.key;
client_max_body_size 20m;
proxy_read_timeout 600s;
location / { try_files $uri @app; }
location @app {
include uwsgi_params;
# Replace this, this depends on how you configure the app
uwsgi_pass unix:/tmp/app_socket.sock;
uwsgi_read_timeout 600s;
uwsgi_send_timeout 600s;
}
location /static {
alias /var/your_static_files_on_server;
}
location /media {
set $s3_bucket 's3-bucket-name.s3.amazonaws.com';
set $url_full '$1';
proxy_http_version 1.1;
proxy_set_header Host $s3_bucket;
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header Set-Cookie;
proxy_ignore_headers "Set-Cookie";
proxy_buffering off;
proxy_intercept_errors on;
# use google dns
resolver 8.8.4.4 8.8.8.8 valid=300s;
resolver_timeout 10s;
proxy_pass http://$s3_bucket$url_full;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment