41 lines
1.7 KiB
Text
41 lines
1.7 KiB
Text
server {
|
|
server_name betaapicsa.tradhox.com apicsa.tradhox.com;
|
|
|
|
location / {
|
|
# Handle CORS preflight requests directly in Nginx
|
|
if ($request_method = 'OPTIONS') {
|
|
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, PATCH' always;
|
|
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
|
add_header 'Access-Control-Max-Age' 1728000 always;
|
|
add_header 'Content-Type' 'text/plain; charset=utf-8' always;
|
|
add_header 'Content-Length' 0 always;
|
|
return 204;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:8081;
|
|
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-Proto $scheme;
|
|
}
|
|
|
|
listen 443 ssl; # managed by Certbot
|
|
ssl_certificate /etc/letsencrypt/live/betaapicsa.tradhox.com/fullchain.pem; # managed by Certbot
|
|
ssl_certificate_key /etc/letsencrypt/live/betaapicsa.tradhox.com/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 = apicsa.tradhox.com) {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
if ($host = betaapicsa.tradhox.com) {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
listen 80;
|
|
server_name betaapicsa.tradhox.com apicsa.tradhox.com;
|
|
return 404;
|
|
}
|