| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- # Nginx配置示例 - 工资发放管理系统
- # 文件位置: /etc/nginx/conf.d/payroll.conf 或 /etc/nginx/sites-available/payroll
- server {
- listen 80;
- server_name your-domain.com; # 修改为您的域名或IP
-
- # 访问日志
- access_log /var/log/nginx/payroll_access.log;
- error_log /var/log/nginx/payroll_error.log;
-
- # 前端静态文件
- root /var/www/payroll-web;
- index index.html;
-
- # 前端路由配置 - Vue Router history模式
- location / {
- try_files $uri $uri/ /index.html;
-
- # 设置缓存
- expires 7d;
- add_header Cache-Control "public, immutable";
- }
-
- # API接口代理到后端
- location /api/ {
- proxy_pass http://localhost:8080/api/;
-
- # 代理头设置
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
-
- # 超时设置
- proxy_connect_timeout 60s;
- proxy_send_timeout 60s;
- proxy_read_timeout 60s;
-
- # 缓冲设置
- proxy_buffering on;
- proxy_buffer_size 8k;
- proxy_buffers 8 8k;
-
- # 禁用缓存(API接口)
- add_header Cache-Control "no-cache, no-store, must-revalidate";
- }
-
- # 静态资源缓存优化
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
- expires 30d;
- add_header Cache-Control "public, immutable";
- }
-
- # Gzip压缩
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_types text/plain text/css text/xml text/javascript
- application/json application/javascript application/xml+rss
- application/rss+xml font/truetype font/opentype
- application/vnd.ms-fontobject image/svg+xml;
- }
- # HTTPS配置示例(推荐生产环境使用)
- # server {
- # listen 443 ssl http2;
- # server_name your-domain.com;
- #
- # # SSL证书配置
- # ssl_certificate /path/to/your/cert.pem;
- # ssl_certificate_key /path/to/your/key.pem;
- #
- # # SSL安全设置
- # ssl_protocols TLSv1.2 TLSv1.3;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- #
- # # 其他配置同上...
- # root /var/www/payroll-web;
- # index index.html;
- #
- # location / {
- # try_files $uri $uri/ /index.html;
- # }
- #
- # location /api/ {
- # proxy_pass http://localhost:8080/api/;
- # proxy_set_header Host $host;
- # proxy_set_header X-Real-IP $remote_addr;
- # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- # proxy_set_header X-Forwarded-Proto $scheme;
- # }
- # }
- # HTTP跳转到HTTPS
- # server {
- # listen 80;
- # server_name your-domain.com;
- # return 301 https://$server_name$request_uri;
- # }
|