創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!
前鋒網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)自2013年起到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。小編給大家分享一下Nginx反向代理多域名的HTTP和HTTPS服務(wù)怎么實(shí)現(xiàn),希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討方法吧!
當(dāng)前Nginx已經(jīng)反向代理了兩個(gè)網(wǎng)站,分別是基于Windows的IIS和Linux的Apach服務(wù)器,提供網(wǎng)頁服務(wù)。
現(xiàn)在有新項(xiàng)目的網(wǎng)頁需要對(duì)外提供服務(wù),需要在代理服務(wù)器上增加另外一個(gè)網(wǎng)站,使用HTTPS訪問以及HTTP自動(dòng)跳轉(zhuǎn)HTTPS。由于新網(wǎng)頁是靜態(tài)頁面,所以使用Docker部署在Nginx代理服務(wù)器上。相關(guān)的certificates是通過let's encrypt來獲取的,都是單獨(dú)的證書,沒有申請(qǐng)通配符形式的證書。
在Nginx代理端部署SSL證書即可,后端不需要部署SSL也可以實(shí)現(xiàn)HTTPS訪問。
Nginx代理服務(wù)器配置:
worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /usr/local/nginx/conf/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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; upstream dx.exzel.co.nz { server 127.0.0.1:8080; } upstream mybusiness.exzel.co.nz { server 192.168.1.252:443; } server { listen 80; server_name dx.exzel.co.nz; rewrite ^(.*) https://dx.exzel.co.nz permanent; } server { listen 443; server_name dx.exzel.co.nz; ssl on; ssl_certificate /etc/letsencrypt/live/dx.exzel.co.nz/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/dx.exzel.co.nz/privkey.pem; ssl_session_timeout 5m; 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; access_log /var/log/nginx/ccieerror.log ; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://dx.exzel.co.nz; } } server { listen 80; server_name mybusiness.exzel.co.nz; rewrite ^(.*) https://mybusiness.exzel.co.nz permanent; } server { listen 443; server_name mybusiness.exzel.co.nz; ssl on; ssl_certificate /etc/letsencrypt/live/mybusiness.exzel.co.nz/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mybusiness.exzel.co.nz/privkey.pem; ssl_session_timeout 5m; 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; access_log /var/log/nginx/mybusiness.log ; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://mybusiness.exzel.co.nz; } } server { listen 80; server_name www.empnz.co.nz empnz.co.nz; location / { proxy_pass http://192.168.1.15 ; } } }