This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
nginx.conf
47 lines (40 loc) · 1.63 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
# 设置nginx启动
# systemctl enable nginx
server {
listen 8080;
server_name www.pythonstock.com;
root /usr/share/nginx/html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# 开启gzip
gzip on;
# 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
gzip_min_length 1k;
# gzip 压缩级别 1-10
gzip_comp_level 2;
# 进行压缩的文件类型。
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
# 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_vary on;
access_log /var/log/nginx/stock.access.log main;
error_log /var/log/nginx/stock.error.log warn;
# https://medium.com/aviabird/413-414-request-url-entity-too-large-error-nginx-b6dcece6f5dd
# 解决GET 参数过长问题。
client_max_body_size 10M;
large_client_header_buffers 4 20k;
location ^~ /static/ {
access_log off;
# 需要把源代码,再下载一遍。
root /data/pythonstock/stock/web;
expires 30d; # 设置30天超时
# 参考 https://www.cnblogs.com/kevingrace/p/10459429.html
# add_header Cache-Control max-age=360000;
}
location / {
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9999;
expires 0;
}
}