Nginx使用域名监听80端口,指向不同服务器
找到nginx.conf编辑
编辑完记得重启
#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; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; ##########################主要配置################################ server { listen 80; #监听的端口 server_name abc.wsycoon.cn; #域名 location / { proxy_buffering off; #重定向 proxy_pass http://xxx.xxx.xxx.xxx:808; #实际你要请求的地址 } server { listen 80; server_name abcd.wsycoon.xyz; location / { proxy_redirect off; proxy_pass http://xxx.xxx.xxx.xxx:8080; } } ################################################################ # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }