| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #user root root;
- worker_processes 1; # 设置值和CPU核心数一致
- #error_log logs/error.log; # 日志位置和日志级别
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- pid logs/nginx.pid;
- # Specifies the value for maximum file descriptors that can be opened by this process.
- worker_rlimit_nofile 65535;
- events {
- worker_connections 1024;
- }
- http {
- include 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"';
-
- server_names_hash_bucket_size 128;
- client_header_buffer_size 32k;
- large_client_header_buffers 4 32k;
- client_max_body_size 8m;
-
- #access_log logs/access.log main;
-
- server_tokens off;
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 60;
- tcp_nodelay on;
-
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.0;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css application/xml;
- gzip_vary on;
-
- # limit_zone crawler $binary_remote_addr 10m;
-
- upstream tomcat-patrol-app { # patrol-app
- server localhost:8898;
- }
- upstream tomcat-patrol-web { # patrol-web
- server localhost:8899;
- }
- # 下面是server虚拟主机的配置
- server {
- listen 80; # 监听端口
- server_name localhost; # 域名
- index index.html index.htm index.php;
- #access_log logs/host.access.log main;
-
- # 后端小程序接口网关
- location ^~ /patrol-app/ { # /patrol-app 开头代理到 tomcat-patrol-app
- 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_pass http://tomcat-patrol-app/;
- }
-
- # 后端接口网关
- location ^~ /patrol-web/ { # /patrol-web 开头代理到 tomcat-patrol-web
- 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_pass http://tomcat-patrol-web/;
- }
-
- # 静态资源
- location ^~ /media {
- root E:/workspace-git/idea/spring-boot;
- }
- # 需要鉴权的资源
- location ^~ /mysql { #--with-http_auth_request_module
- auth_request /auth-proxy;
- add_header Access-Control-Allow-Origin * always;
- add_header Access-Control-Allow-Headers *;
- add_header Access-Control-Allow-Methods *;
- if ($request_method = 'OPTIONS') {
- return 204;
- }
- root E:/workspace-git/idea/spring-boot;
- }
-
- # 授权校验
- location /auth-proxy {
- internal;
- proxy_pass_request_body off; # 不转发body给鉴权
- proxy_set_header Content-Length ""; # 不转发body给鉴权
- proxy_pass "http://localhost:8899/v1/system/user/check/authorize"; # 鉴权地址
- }
-
- # VUE 网页
- location ^~ / { # /开头请求root,注意请求时带有/。
- root D:/web/;
- try_files $uri $uri/ /index.html; # 解决刷新后404问题
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
- expires 30d;
- }
- location ~ .*\.(js|css)?$ {
- expires 15d;
- }
- }
- }
|