Skip to content

Instantly share code, notes, and snippets.

@marcelogrsp
Created June 4, 2021 12:50
Show Gist options
  • Save marcelogrsp/b3ac2493e4d35571e64693ade005dd63 to your computer and use it in GitHub Desktop.
Save marcelogrsp/b3ac2493e4d35571e64693ade005dd63 to your computer and use it in GitHub Desktop.
NGINX
server {
listen 80 default_server;
listen [::]:80 default_server;
location /api {
proxy_pass http://localhost:5000/api;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $cors '';
if ($http_origin ~ '^https?://(localhost|www\.condescending-spence-081ef7.netlify.app|www\.vsbapi.bytemine.io)') {
set $cors 'true';
}
if ($cors = 'true') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
add_header 'Access-Control-Expose-Headers' 'Authorization' always;
}
if ($request_method = 'OPTIONS') {
# Tell client that this pre-flight info is valid for 20 days
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
# server {
# location /api {
# proxy_pass http://localhost:5000/api;
# }
# server_name vsbapi.bytemine.io www.vsbapi.bytemine.io;
# # managed by Certbot
# listen [::]:443 ssl ipv6only=on; # managed by Certbot
# listen 443 ssl; # managed by Certbot
# ssl_certificate /etc/letsencrypt/live/vsbapi.bytemine.io/fullchain.pem; # managed by Certbot
# ssl_certificate_key /etc/letsencrypt/live/vsbapi.bytemine.io/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.vsbapi.bytemine.io) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# if ($host = vsbapi.bytemine.io) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# listen 80 ;
# listen [::]:80 ;
# server_name vsbapi.bytemine.io www.vsbapi.bytemine.io;
# return 404; # managed by Certbot
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment