目录结构:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ├── dhparam.pem ├── fastcgi_params ├── logs │ ├── access.log │ ├── error.log │ ├── limsweb.access.log │ ├── limsweb.error.log ├── mime.types ├── nginx.conf ├── nginxconfig.io │ ├── general.conf │ ├── proxy.conf │ └── security.conf ├── scgi_params ├── sites-enabled │ └── limsweb.conf ├── ssl │ ├── ilims.mylims.com.key │ ├── ilims.mylims.com_bundle.crt │ └── ilims.mylims.com_bundle.pem ├── uwsgi_params └── www └── limsweb └── public
注意 general.conf 中需要注释掉 拦截 assets, media的配置:
1 2 3 4 # location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { # expires 7d; # access_log off; # }
完整配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 upstream apicluster{ server 10.10.0.117:30008; server 10.10.0.119:30008; } server { listen 443 ssl http2; listen [::]:433 http2; server_name ilims.mylims.com; root /var/www/limsweb/public; charset utf-8; # SSL ssl_certificate /etc/nginx/ssl/ilims.mylims.com_bundle.crt; ssl_certificate_key /etc/nginx/ssl/ilims.mylims.com.key; # security include /etc/nginx/nginxconfig.io/security.conf; # logging access_log /var/log/nginx/limsweb.access.log; error_log /var/log/nginx/limsweb.error.log warn; # index.html fallback location / { # root /var/www/limsweb/public; try_files $uri $uri/ @router; index index.html index.htm; error_page 405 =200 http://$host$request_uri; location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { expires 7d; access_log off; } } #代理后端接口 location /api/ { proxy_pass http://apicluster; #转发请求的地址 rewrite ^/api/(.*)$ /$1 break; include /etc/nginx/nginxconfig.io/proxy.conf; } # 以下为 minio 配置 # To allow special characters in headers ignore_invalid_headers off; # Allow any size file to be uploaded. # Set to a value such as 1000m; to restrict file size to a specific value client_max_body_size 0; # To disable buffering proxy_buffering off; # 代理minio location /s3/ { rewrite ^/s3/(.*)$ /$1 break; # Proxy headers proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; # proxy_set_header Host $http_host; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Forwarded $proxy_add_forwarded; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_hide_header X-Powered-By; # Proxy timeouts proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; proxy_cache_bypass $http_upgrade; chunked_transfer_encoding off; proxy_pass http://10.10.0.103:9100; # 转发请求的地址 } # minio 配置结束 location /limscap/ { return 404; } # websocket location /hubs/ { proxy_pass http://apicluster; #转发请求的地址 include /etc/nginx/nginxconfig.io/proxy.conf; } location @router { rewrite ^.*$ /index.html last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # additional config include /etc/nginx/nginxconfig.io/general.conf; } # HTTP redirect server { listen 80; listen [::]:80; server_name localhost; return 301 https://example.com$request_uri; }