nginx 1.16 配置反向代理,http,https,ssl

需求 之前云服务上仅部署了门户网站,后来要做小程序开发,还有各项目网站。之前是通过域名+端口访问,

现改为启用二级域名,共用公网IP,80(http)、443(https)端口,通过nginx按域名做反向代理,

第一步:配置域名解析到主域名IP

第二步:服务器所需要的web服务部署起来(http协议)

第三步:安装nginx(这里使用的是1.16版本,不同版本配置可能不同),配置 conf/nginx.conf 如下:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    
    # 门户
    server {
        listen       80;
        server_name  www.xxx.com xxx.com;
        location / {
            proxy_pass   http://127.0.0.1:8001;
        }
    }

    # yy
    server {
        listen       80;
        server_name  yy.xxx.com;
        location / {
            proxy_pass   http://127.0.0.1:8080;
        }
    }
    
    # 微信
    server {
        listen       443 ssl;
        server_name  wx.xxx.com;
	    ssl_certificate       cert/2281990_wx.kykjsoft.com.pem;
	    ssl_certificate_key   cert/2281990_wx.kykjsoft.com.key;
	    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	    ssl_prefer_server_ciphers on;
	    ssl_session_timeout 5m;
		
        location / {
            proxy_pass   http://127.0.0.1:9080;
        }
    }
}

## 启动服务:start nginx
## 重启服务:nginx -s reload

你可能感兴趣的:(Web服务器部署)