-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathnginx.conf
executable file
·134 lines (113 loc) · 5.01 KB
/
nginx.conf
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# auto detects a good number of processes to run
worker_processes auto;
#Provides the configuration file context in which the directives that affect connection processing are specified.
events {
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
worker_connections 8000;
# Tells the worker to accept multiple connections at a time
multi_accept on;
}
http {
# don't send the nginx version number in error pages and Server header
server_tokens off;
# what times to include
include /etc/nginx/mime.types;
# what is the default one
default_type application/octet-stream;
# Sets the path, format, and configuration for a buffered log write
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $upstream_addr '
'"$http_referer" "$http_user_agent"';
server {
# compress files
gzip on;
# listen on port 80
listen 80;
# save logs here
access_log /var/log/nginx/access.log compression;
# config to don't allow the browser to render the page inside an frame or iframe and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header, to disable content-type sniffing on some browsers.
add_header X-Content-Type-Options nosniff;
# This header enables the Cross-site scripting (XSS) filter built into most recent web browsers. It's usually enabled by default anyway, so the role of this header is to re-enable the filter for this particular website if it was disabled by the user.
add_header X-XSS-Protection "1; mode=block";
# with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy),
# https://www.cspisawesome.com/
# set $DEFAULT "default-src 'none'";
# set $SCRIPT "script-src 'self'";
# set $SCRIPT "${SCRIPT} 'unsafe-inline'";
# set $SCRIPT "${SCRIPT} https://www.google.com";
# set $SCRIPT "${SCRIPT} https://www.gstatic.com";
# set $SCRIPT "${SCRIPT} https://cdn.jsdelivr.net";
# set $SCRIPT "${SCRIPT} https://www.google-analytics.com";
# set $STYLE "style-src 'self'";
# set $STYLE "${STYLE} 'unsafe-inline'";
# set $STYLE "${STYLE} https://cdn.jsdelivr.net";
# set $IMG "img-src 'self'";
# set $IMG "${IMG} https://www.google-analytics.com";
# set $IMG "${IMG} data:";
# set $FONT "font-src 'self'";
# set $FONT "${FONT} https://cdn.jsdelivr.net";
# set $CONNECT "connect-src 'self'";
# set $CONNECT "${CONNECT} https://api.opentezos.com";
# set $CONNECT "${CONNECT} https://www.google-analytics.com";
# set $FRAME "frame-src 'self'";
# set $FRAME "${FRAME} https://www.google.com";
# set $OBJECT "object-src 'none'";
# set $MEDIA "media-src 'none'";
# set $MANIFEST "manifest-src 'self'";
# set $WORKER "worker-src 'self'";
# set $WORKER "${WORKER} data:";
# add_header Content-Security-Policy "${DEFAULT}; ${SCRIPT}; ${STYLE}; ${IMG}; ${FONT}; ${CONNECT}; ${FRAME}; ${OBJECT}; ${MEDIA}; ${MANIFEST}; ${WORKER};";
# only allow cloudflare's IPs
# allow 173.245.48.0/20;
# allow 103.21.244.0/22;
# allow 103.22.200.0/22;
# allow 103.31.4.0/22;
# allow 141.101.64.0/18;
# allow 108.162.192.0/18;
# allow 190.93.240.0/20;
# allow 188.114.96.0/20;
# allow 197.234.240.0/22;
# allow 198.41.128.0/17;
# allow 162.158.0.0/15;
# allow 104.16.0.0/12;
# allow 172.64.0.0/13;
# allow 131.0.72.0/22;
# allow 2400:cb00::/32;
# allow 2606:4700::/32;
# allow 2803:f800::/32;
# allow 2405:b500::/32;
# allow 2405:8100::/32;
# allow 2a06:98c0::/29;
# allow 2c0f:f248::/32;
# deny all;
# where the root here
root /var/www;
# what file to server as index
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to redirecting to index.html
try_files $uri $uri/ /index.html;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
try_files $uri =404;
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# Javascript and CSS files
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1d;
access_log off;
add_header Cache-Control "public";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
}
}