#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; #监听端口 server_name #绑定域名 return 301 #80端口重定向至https autoindex on; #自动显示目录 默认为off autoindex_exact_size off; #人性化方式显示文件大小否则以byte显示 默认为on autoindex_localtime on; #按服务器时间显示,否则以gmt时间显示 默认off location / { root html; #根目录 index index.html index.htm; #默认首页 } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #php文件配置 location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.2-fpm.sock; } } #新服务 https server { listen 443 ssl; server_name www.heanny.cn; ssl on; ssl_certificate ssl/1.pem; #证书路径 ssl_certificate_key ssl/2.key; #密钥路径 #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } } #负载均衡 upstream register_http { #ip_hash; #针对ip进行hash,还有url_hash server 127.0.0.1:8801; 服务器1 server 122.115.230.174:8801; 服务器2 # fair; 根据延时智能负载(第三方插件,需安装) } #负载均衡服务demo server { listen 80; listen 443 ssl; server_name nginx.heanny.cn; ssl on; ssl_certificate ssl/1.pem; ssl_certificate_key ssl/2.key; #端口跳转 if ($server_port = 80) { rewrite ^(.*)$ https://$host$1 permanent; } location / { proxy_pass http://register_http; } } # register http 8801 server { listen 8801; #api重定向 location ~ /api/* { proxy_pass http://127.0.0.1:8888; # proxy_pass http://register_http; } location / { root html_register; index index.html; } } server { listen 80; listen 443 ssl; server_name admin.game.coccnet.com; ssl on; ssl_certificate /usr/local/nginx/html_register/ssl/1.pem; ssl_certificate_key /usr/local/nginx/html_register/ssl/2.key; client_max_body_size 50m; #文件大小限制 client_header_timeout 1m; #读取请求头超时 408 client_body_timeout 1m; #读取实体超时 403 proxy_connect_timeout 60s; #等待服务器响应超时 proxy_read_timeout 1m; #服务器响应时间 proxy_send_timeout 1m; #服务器反应时间 location ~ /api/* { proxy_pass http://127.0.0.1:8888; } location / { root html_game_admin; #proxy_set_header X-Real-IP $remote_addr; index index.html; if (!-e $request_filename) { rewrite ^/(.*) /index.html last; break; } } } }
暂无评论,还不快来坐沙发...