Created
October 3, 2016 22:39
-
-
Save equivalent/1dd25306eb28283fa83a920f3134e53e to your computer and use it in GitHub Desktop.
Nginx example of using CORS
This file contains 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 mycoolapp { | |
server unix:///var/run/puma.sock; | |
} | |
server { | |
listen 80; | |
server_name www.my-cool-website.com; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name www.my-cool-website.com; | |
root /app/public; | |
ssl_certificate /shared/certs/ssl.crt; | |
ssl_certificate_key /shared/certs/ssl.key; | |
client_max_body_size 20m; | |
location / { | |
add_header 'Access-Control-Allow-Origin' '*'; # change this to more strict CDN host. e.g.: 'xxxxxxxxxxxxxx.cloudfront.net' | |
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $server_name; | |
proxy_set_header Client-IP $remote_addr; | |
proxy_pass http://mycoolapp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example of socket puma application https://github.com/equivalent/dummy-sinatra-puma-socket-docker-app