Nginx实现根据域名http、https分发配置示例
tomcat端口:8080 做好虚拟主机
nginx端口:80 根据域名分派
在conf/nginx.conf中的http中增加
代码如下:
include www.jb51.net.conf
新建conf/www.jb51.net.conf,内容如下:
代码如下:
server {
listen 80;
server_name www.jb51.net;
listen 80;
server_name www.jb51.net;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
}