nginx代理同一ip,不同埠,域名服務
阿新 • • 發佈:2018-12-23
****************************************本文只再本地測試,未再正式伺服器上配置測試過*************************************************************
1) 找到 C:\Windows\System32\drivers\etc hosts 檔案,新增
127.0.0.1 www.haodult.com
127.0.0.1 admin.haodult.com
2) nginx配置
********* 1)root 配置靜態檔案路徑 ; 2) proxy_pass ip 埠路徑#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; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; server { listen 80; server_name www.haodult.com; access_log logs/access.log; error_log logs/error.log; #access_log logs/host.access.log main; location / { index index.html index.htm; root H:\test\uiweb; proxy_pass http://127.0.0.1:8081; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name admin.haodult.com; access_log logs/access.log; error_log logs/error.log; #access_log logs/host.access.log main; location / { index index.html index.htm; root H:\test\tool; proxy_pass http://127.0.0.1:8083; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }