47 lines
1.6 KiB
Nginx Configuration File
47 lines
1.6 KiB
Nginx Configuration File
# 设置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:9090;
|
|
expires 0;
|
|
}
|
|
} |