🚒 Trying out nginx for CORS mitigation
This commit is contained in:
32
proxy.conf
Normal file
32
proxy.conf
Normal file
@@ -0,0 +1,32 @@
|
||||
upstream api {
|
||||
# Could be host.docker.internal - Docker for Mac/Windows - the host itself
|
||||
# Could be your API in a appropriate domain
|
||||
# Could be other container in the same network, like container_name:port
|
||||
server ghost:8050;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8050;
|
||||
server_name ghost;
|
||||
|
||||
location / {
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
|
||||
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
|
||||
add_header 'Content-Type' 'application/json';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
|
||||
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
|
||||
|
||||
proxy_pass http://api/;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user