Created
February 28, 2019 09:33
-
-
Save sushant12/b41fa4c758f63a9db32544d1d922d928 to your computer and use it in GitHub Desktop.
Nginx setup for hosting static sites
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
upstream puma { | |
server unix://home/deploy/apps/pte_backend/shared/tmp/sockets/pte_backend-puma.sock fail_timeout=0; | |
} | |
server { | |
server_name api.houseofenglish.online; | |
root /home/deploy/apps/pte_backend/current/public; | |
try_files $uri/index.html $uri @puma; | |
location @puma { | |
proxy_pass http://puma; | |
proxy_set_header 'Access-Control-Allow-Origin' 'https://creator.houseofenglish.online'; | |
proxy_set_header 'Access-Control-Allow-Origin' 'https://www.houseofenglish.online'; | |
proxy_set_header 'Access-Control-Allow-Origin' 'https://houseofenglish.online'; | |
proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH, HEAD'; | |
proxy_set_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin'; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/houseofenglish.online/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/houseofenglish.online/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
server_name creator.houseofenglish.online; | |
index index.html index.htm; | |
root /home/deploy/apps/pte_creator/current; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
location ~* \.html?$ { | |
expires -1; | |
add_header Pragma "no-cache"; | |
add_header Cache-Control "no-store, must-revalidate"; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/houseofenglish.online/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/houseofenglish.online/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
server_name houseofenglish.online www.houseofenglish.online; | |
index index.html index.html; | |
root /home/deploy/apps/pte_app/current; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
location ~* \.html?$ { | |
expires -1; | |
add_header Pragma "no-cache"; | |
add_header Cache-Control "no-store, must-revalidate"; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/houseofenglish.online/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/houseofenglish.online/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
if ($host = www.houseofenglish.online) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
} | |
server { | |
if ($host = www.houseofenglish.online) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
if ($host = houseofenglish.online) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name houseofenglish.online www.houseofenglish.online; | |
return 404; # managed by Certbot | |
} | |
server { | |
if ($host = api.houseofenglish.online) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name api.houseofenglish.online; | |
return 404; # managed by Certbot | |
} | |
server { | |
if ($host = creator.houseofenglish.online) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name creator.houseofenglish.online; | |
return 404; # managed by Certbot | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment