Files
Yact-Backup/nginx.conf
2025-07-13 12:02:30 +08:00

88 lines
2.3 KiB
Nginx Configuration File

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
server_tokens off;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_types text/plain application/x-JavaScript text/css application/xml;
# proxy cache test
upstream halocore {
server halo:8090 weight=1 max_fails=2 fail_timeout=0;
}
# proxy cache test end.
#ssl on;
ssl_certificate /etc/nginx/certs/www.yact.com.cn.pem;
ssl_certificate_key /etc/nginx/certs/www.yact.com.cn.key;
proxy_cache_path /data/nginx/cache keys_zone=mycache:6000m inactive=3d max_size=500g;
# include /etc/nginx/conf.d/*.conf;
# 80端口重定向到443
server {
listen 80;
listen [::]:80;
server_name yact.com.cn www.yact.com.cn;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yact.com.cn www.yact.com.cn;
client_max_body_size 1024m;
location / {
# proxy_pass http://halo:8090;
add_header X-Cache $upstream_cache_status;
proxy_pass http://halocore;
proxy_cache_key $uri$is_args$args;
}
location ~ (^/).*\.(gif|jpg|jpeg|png|js|css|html|cab|bmp|ico|svg|eot|ttf|woff|woff2)$ {
# proxy_buffering on;
proxy_pass http://halocore;
proxy_cache mycache;
proxy_cache_valid 200 304 12h;
proxy_cache_valid any 10m;
add_header Nginx-Cache "$upstream_cache_status";
proxy_cache_key $host$uri$is_args$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}