一、安裝nginxhtml
yum -y install nginxnginx
二、啓動nginxtomcat
service nginx start服務器
三、訪問(nginx默認是80端口)curl
curl 127.0.0.1測試
四、域名子綁定網站
編輯文件/etc/nginx/conf.d/default.conf,在底部加入下面代碼,完成前幾章所述4個端口的子域名綁定阿里雲
server{ listen 80; server_name tomcat.bingzhenmifan.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:14802; } } server{ listen 80; server_name jetty.bingzhenmifan.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:14808; } } server{ listen 80; server_name resin8080.bingzhenmifan.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:8080; } } server{ listen 80; server_name resin14805.bingzhenmifan.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:14805; } }
五、重啓nginxurl
service nginx restartspa
六、訪問測試
依次訪問上面4個域名:tomcat.bingzhenmifan.com、jetty.bingzhenmifan.com、resin8080.bingzhenmifan.com、resin14805.bingzhenmifan.com
注意:若是域名沒有備案的話,在本地是打不開網站的,能夠在雲服務器上使用curl命令訪問
七、域名備案
登陸阿里雲,點擊右上角【備案】,按步驟完成備案便可