summaryrefslogtreecommitdiff
path: root/conf/nginx/site.conf
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-03-29 22:29:56 -0400
committerFreya Murphy <freya@freyacat.org>2024-03-29 22:29:56 -0400
commit944b6b0526032ad8c1b4a2612d6723bec75e0e4c (patch)
treed3da5584df33a7878c087622b4fc2ec2883cf880 /conf/nginx/site.conf
downloadxssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.tar.gz
xssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.tar.bz2
xssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.zip
start database (user and post), and initial barebones home page
Diffstat (limited to 'conf/nginx/site.conf')
-rw-r--r--conf/nginx/site.conf95
1 files changed, 95 insertions, 0 deletions
diff --git a/conf/nginx/site.conf b/conf/nginx/site.conf
new file mode 100644
index 0000000..fd4cbe6
--- /dev/null
+++ b/conf/nginx/site.conf
@@ -0,0 +1,95 @@
+server_tokens off;
+
+upstream postgrest {
+ server rest:3000 fail_timeout=0;
+}
+
+upstream swagger {
+ server swagger:3000 fail_timeout=0;
+}
+
+server {
+ listen 80;
+ server_name localhost;
+
+ keepalive_timeout 70;
+ sendfile on;
+ client_max_body_size 2m;
+
+ error_log /var/log/nginx/error.log;
+ access_log /var/log/nginx/access.log;
+
+ root /opt/xssbook;
+
+ gzip on;
+ gzip_vary on;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.1;
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon;
+
+ location /api/ {
+
+ if ($request_method = 'OPTIONS') {
+ add_header 'Access-Control-Allow-Origin $http_origin' always;
+ # Om nom nom cookies
+ add_header 'Access-Control-Allow-Credentials' 'true';
+ 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-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ # 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 $http_origin' always;
+ add_header 'Access-Control-Allow-Credentials' 'true';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+ add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ }
+
+ if ($request_method = 'GET') {
+ add_header 'Access-Control-Allow-Origin $http_origin' always;
+ add_header 'Access-Control-Allow-Credentials' 'true';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+ add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ }
+
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_set_header Accept-Encoding "";
+ proxy_redirect off;
+
+ default_type application/json;
+ add_header Content-Location /api/$upstream_http_content_location;
+ proxy_set_header Connection "";
+ proxy_http_version 1.1;
+ proxy_pass http://postgrest/;
+ }
+
+ location /apidocs {
+ proxy_http_version 1.1;
+ proxy_pass http://swagger;
+ }
+
+ location /favicon.ico {
+ root /opt/xssbook/public;
+ add_header Cache-Control "public, max-age=108000";
+ }
+
+ location /public {
+ try_files $uri =404;
+ add_header Cache-Control "public, max-age=108000";
+ }
+
+ location / {
+ include fastcgi_params;
+ fastcgi_pass php:9000;
+ fastcgi_param SCRIPT_FILENAME $document_root/index.php;
+ }
+
+}