From: Nicolas Boisselier Date: Thu, 7 Mar 2019 02:47:59 +0000 (+0000) Subject: nginx X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=6c54540c759285e09850bc3a67503afb06535674;p=nb.git nginx --- diff --git a/etc/nginx/cors b/etc/nginx/cors new file mode 120000 index 00000000..30ec88a9 --- /dev/null +++ b/etc/nginx/cors @@ -0,0 +1 @@ +cors.conf \ No newline at end of file diff --git a/etc/nginx/cors.conf b/etc/nginx/cors.conf new file mode 100644 index 00000000..65af5189 --- /dev/null +++ b/etc/nginx/cors.conf @@ -0,0 +1,28 @@ +# cors +if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; + # + # 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; +} +if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; + add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; +} +if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; + add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; +} diff --git a/etc/nginx/https-only.conf b/etc/nginx/https-only.conf new file mode 100644 index 00000000..519d40d7 --- /dev/null +++ b/etc/nginx/https-only.conf @@ -0,0 +1,11 @@ +set $_https_only 0; +if ( $scheme = http ) { set $_https_only 1; } + +if ( $https_only = "") { set $https_only ""; } +if ( $https_only != "") { set $_https_only $https_only; } + +if ( $scheme = https ) { set $_https_only 0; } +# Live is behind a load balancer which do only http queries +if ($http_x_forwarded_proto = "https") { set $_https_only 0; } + +if ( $_https_only = 1 ) { return 301 https://$host$request_uri; } diff --git a/etc/nginx/inc b/etc/nginx/inc new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/etc/nginx/inc @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/etc/nginx/inc/cors b/etc/nginx/inc/cors deleted file mode 100644 index 65af5189..00000000 --- a/etc/nginx/inc/cors +++ /dev/null @@ -1,28 +0,0 @@ -# cors -if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - # - # Custom headers and headers various browsers *should* be OK with but aren't - # - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; - # - # 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; -} -if ($request_method = 'POST') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; - add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; -} -if ($request_method = 'GET') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; - add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; -} diff --git a/etc/nginx/inc/https-only.conf b/etc/nginx/inc/https-only.conf deleted file mode 100644 index 519d40d7..00000000 --- a/etc/nginx/inc/https-only.conf +++ /dev/null @@ -1,11 +0,0 @@ -set $_https_only 0; -if ( $scheme = http ) { set $_https_only 1; } - -if ( $https_only = "") { set $https_only ""; } -if ( $https_only != "") { set $_https_only $https_only; } - -if ( $scheme = https ) { set $_https_only 0; } -# Live is behind a load balancer which do only http queries -if ($http_x_forwarded_proto = "https") { set $_https_only 0; } - -if ( $_https_only = 1 ) { return 301 https://$host$request_uri; } diff --git a/etc/nginx/php-handler-7-fpm.conf b/etc/nginx/php-handler-7-fpm.conf new file mode 100644 index 00000000..062a01b1 --- /dev/null +++ b/etc/nginx/php-handler-7-fpm.conf @@ -0,0 +1 @@ +upstream php-handler { server unix:///var/run/php/php7.0-fpm.sock; }