mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-27 23:19:40 +08:00
58 lines
1.4 KiB
Nginx Configuration File
58 lines
1.4 KiB
Nginx Configuration File
pid /tmp/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 /dev/stdout main;
|
||
error_log /dev/stderr;
|
||
|
||
client_body_temp_path /tmp/client_temp;
|
||
proxy_temp_path /tmp/proxy_temp;
|
||
fastcgi_temp_path /tmp/fastcgi_temp;
|
||
uwsgi_temp_path /tmp/uwsgi_temp;
|
||
scgi_temp_path /tmp/scgi_temp;
|
||
|
||
# 基本设置
|
||
sendfile on;
|
||
tcp_nopush on;
|
||
tcp_nodelay on;
|
||
keepalive_timeout 65;
|
||
types_hash_max_size 2048;
|
||
|
||
# Gzip 压缩
|
||
gzip on;
|
||
gzip_vary on;
|
||
gzip_min_length 1024;
|
||
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
||
|
||
server {
|
||
listen 8080;
|
||
server_name localhost;
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
|
||
include /etc/nginx/locations/*.conf;
|
||
|
||
# 处理前端路由(SPA)
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 静态资源缓存
|
||
location ~* \.(js|css|png|svg|ttf)$ {
|
||
expires 1y;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
}
|
||
}
|