nginx配置反向代理及根据域名设置不同的反向代理
参考以下配置nginx.conf
http { #配置反向代理服务器 upstream server1{ server 127.0.0.1:8000; }
server { listen 443 ssl; #指向server1 location / { proxy_pass http://server1; } location /static/ { root /usr/local/djo/typeidea/typeidea/themes/default/static; } }
}
当有多个域名需要不同的反向代理设置时,参考如下:
#user nobody;
worker_processes1; events { worker_connections1024; } http { include mime.types; default_type application/octet-stream; sendfileon; keepalive_timeout65; server { listen80; server_name manage.leyou.com; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:9001; proxy_connect_timeout600; proxy_read_timeout600; } } server { listen80; server_name api.leyou.com; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:10010; proxy_connect_timeout600; proxy_read_timeout600; } } }
——————————
更多Nginx安装配置调优配置,参考文档:https://hupingzhi.cn/post/6/