summaryrefslogtreecommitdiff
path: root/conf/nginx/site.conf
blob: 04c75ca6a28e70e9de079b79dde2393d213e5c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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/ {
		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 'Access-Control-Allow-Origin' '*';
		add_header Content-Location  /api/$upstream_http_content_location;
		proxy_set_header  Connection "";
		proxy_http_version 1.1;
		proxy_pass http://postgrest/;
	}

	location /apidocs {
		add_header 'Access-Control-Allow-Origin' '*';
		proxy_http_version 1.1;
		proxy_pass http://swagger;
	}

	location /favicon.ico {
		add_header 'Access-Control-Allow-Origin' '*';
		root /opt/xssbook/public;
		add_header Cache-Control "public, max-age=108000";
	}

	location /public {
		add_header 'Access-Control-Allow-Origin' '*';
		try_files $uri =404;
		add_header Cache-Control "public, max-age=108000";
	}

	location / {
		add_header 'Access-Control-Allow-Origin' '*';
		root /opt/xssbook/web;
		include fastcgi_params;
		fastcgi_pass php:9000;
		fastcgi_param SCRIPT_FILENAME $document_root/index.php;
	}

}