plane/nginx/nginx.conf
2023-03-08 15:48:21 +05:30

67 lines
2.2 KiB
Nginx Configuration File

upstream plane {
server localhost:80;
}
worker_processes 1;
error_log /var/log/nginx/error.log;
server_tokens off;
access_log /var/log/nginx/access.log;
http {
sendfile on;
upstream django {
server planebackend:8000;
}
upstream nextjs {
server planefrontend:3000;
}
server {
listen 80;
root /www/data/;
access_log /var/log/nginx/access.log;
location / {
proxy_pass http://planefrontend:3000/;
proxy_set_header Host $host;
# Simple requests
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD, PUT";
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,Authorization, Origin, X-Requested-With, Accept,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT';
}
location /api/ {
proxy_pass http://planebackend:8000/api/;
proxy_set_header Host $host;
add_header 'Access-Control-Allow-Origin' '*' always;
# Simple requests
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD, PUT";
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,Authorization, Origin, X-Requested-With, Accept,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT', 'HEAD', 'DELETE' ;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}