nginx?
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。
用户权限
1 2 3 4 5
| user root; http { ... }
|
keepalive
1 2
| # keepalive_timeout 0; keepalive_timeout 65;
|
gzip配置
1 2 3 4 5 6 7
| gzip on;
gzip_types text/plain application/javascript application/json;
gzip_vary on;
|
负载均衡
1 2 3 4 5 6 7 8 9 10 11
| http { ... upstream test { # ip_hash; 根据ip分配请求 server 0.0.0.0:9000; server 0.0.0.0:9001; # 加权 server 0.0.0.0:9002 weight=1; } server {} }
|
配置反向代理
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
| http {
... server {
listen 8080;
server_name localhost 本地地址;
charset utf-8;
location / { root /xxx/dist; index index.html index.htm;
try_files $uri /index.html; } location ~ \.(gif|jpg|png|jpeg|svg|eot|ttf|woff|css|js)$ { root /Users/wulin/Desktop/projects/dtlogstatic/dist; expires 7d; } location /log/xxx/1 { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_set_header Connection ""; proxy_pass http://xxx; #****这里填上服务器地址 proxy_redirect default ; } location /log/xxx/2 { ... } } }
|
配置资料
https://www.jianshu.com/p/026d67cc6cb1
https://www.cnblogs.com/tandaxia/p/8810648.html