Merge 496c02ab00
into df6778f673
This commit is contained in:
commit
a58177d99c
1 changed files with 27 additions and 0 deletions
27
nginx.tmpl
27
nginx.tmpl
|
@ -51,6 +51,11 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
|
||||
{{ end }}
|
||||
|
||||
proxy_pass_header Access-Control-Allow-Headers;
|
||||
proxy_pass_header Access-Control-Allow-Methods;
|
||||
proxy_pass_header Access-Control-Allow-Credentials;
|
||||
proxy_pass_header Access-Control-Allow-Origin;
|
||||
|
||||
server {
|
||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||
listen 80;
|
||||
|
@ -145,6 +150,17 @@ server {
|
|||
|
||||
location / {
|
||||
proxy_pass {{ $proto }}://{{ $host }};
|
||||
|
||||
if ({{"$"}}request_method = 'OPTIONS') {
|
||||
add_header Access-Control-Allow-Origin '{{"$"}}http_origin';
|
||||
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
|
||||
add_header Access-Control-Allow-Credentials 'true';
|
||||
add_header Access-Control-Allow-Headers 'Origin,Content-Type,Accept';
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 204;
|
||||
}
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
|
@ -171,6 +187,17 @@ server {
|
|||
|
||||
location / {
|
||||
proxy_pass {{ $proto }}://{{ $host }};
|
||||
|
||||
if ({{"$"}}request_method = 'OPTIONS') {
|
||||
add_header Access-Control-Allow-Origin '{{"$"}}http_origin';
|
||||
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
|
||||
add_header Access-Control-Allow-Credentials 'true';
|
||||
add_header Access-Control-Allow-Headers 'Origin,Content-Type,Accept';
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 204;
|
||||
}
|
||||
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
|
|
Loading…
Reference in a new issue