为了方便以后维护网站,减少手打代码的麻烦,把Nginx的服务器配置扔在这,以后直接Ctrl+C Ctrl+V

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
server {
# Redirect HTTP to HTTPS
listen 80 default_server;
listen [::]:80 default_server;

return 301 https://$host$request_uri;
}

server {
# Remove default_server in each domain's config file if running multiple websites
# If use Cloudflare just let CF fetch origin in https, and no need to redirect here.
#listen 80 default_server;
#listen [::]:80 default_server;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;

#server_name ftm.moe www.ftm.moe;
root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

# SSL Certificates Here
ssl_certificate /etc/ssl/test/test.crt;
ssl_certificate_key /etc/ssl/test/test.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DHE-DSS-DES-CBC3-SHA:DES-CBC3-SHA;
ssl_prefer_server_ciphers on;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

# You know what's this for :lol
location /test/ {
proxy_redirect off;
proxy_pass http://127.0.0.1:10086;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# Custom 404 page
error_page 404 = /404.html;

# Typecho rewrite rules, only uncomment if using typecho
#if (!-e $request_filename) {
# rewrite ^(.*)$ /index.php$1 last;
#}

# Process PHP
location ~ \.php(\/.*)*$ {
# include snippets/fastcgi-php.conf;

fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}

# Security settings and headers
autoindex off;
server_tokens off;
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1";
add_header Referrer-Policy "same-origin";

# Enable HSTS ONLY IF you are SURE your server will ALWAYS have well-configured SSL and a vaild certificate
#add_header Strict-Transport-Security "max-age=11451419";

# Uncomment if this site provides API or something used by other sites.
#add_header Access-Control-Allow-Origin "*";

# Disable log for static resources
location ~ .*\.(js|jpg|ico|jpeg|css|bmp|gif|png|webp|eot|otf|ttf|woff)$ {
access_log off;
}

}