Apache(httpd)實現反向代理

新手一步步搭建本身的網站(服務器->域名->CA認證)html

由於這篇文章是Apache(httpd)的教程,配置了多域名SSL配置nginx

Chrome訪問 https://woodtechblog.tk/  443端口apache

 

Chrome訪問 http://woodtechblog.tk/  80端口服務器

 解釋一下 經過域名訪問網站 http 走的是80端口,https 走的是443端口架構

得出結論:配置的Apache(httpd) 只監聽端口 80 和 443 ide

 

前一篇教程已經部署了SpringBoot應用hello-0.0.1-SNAPSHOT.jar (更多SpringCloud微服務架構教程)微服務

http://www.woodtechblog.tk:8080/hello/小伍 http能夠訪問post

---------------------------------------------------------------網站

疑問:不是說Apache(httpd)只接受 80 和 443 端口的請求嗎,爲何http能夠訪問?spa

-> 由於是8080端口是SpringBoot應用自帶的Tomcat中部署的,因此你訪問的是Tomcat服務器

---------------------------------------------------------------

 

 

https://www.woodtechblog.tk:8080/hello/小伍 https訪問不了

這個問題怎麼解決?-> 反向代理技術 

通常企業都是用 Nginx做爲反向代理,可是我已經配置了Apache不想改了,Apache也能夠實現相同的功能

修改 /etc/httpd/httpd.conf (apache2.2 /etc/httpd/conf/httpd.conf)CentOS

-----------------拓展內容-------------------

Mac自帶Nginx和Apache 

Nginx目錄及經常使用命令(下載的Nginx須要編譯才能運行哦,去根目錄下運行 ./configure 編譯Nginx,須要 gcc 的支持):

/usr/local/etc/nginx

start nginx

nginx -s stop

nginx -s reload

 

Apache httpd目錄及經常使用命令:

/etc/apache2/

sudo apachectl start

sudo apachectl stop

sudo apachectl restart

------------------------------------------

確保195~196沒有註釋

在文件末尾追加反向代理配置

#反向代理

ProxyRequests Off

ProxyPass /ability/payment http://127.0.0.1:8821/payment

ProxyPassReverse /ability/payment http://127.0.0.1:8821/payment

 

ProxyPass /payment/notify http://127.0.0.1:8080/payment/notify

ProxyPassReverse /payment/notify http://127.0.0.1:8080/payment/notify

 

<proxy *>

    AllowOverride None

    Order Deny,Allow

    Allow from all

</proxy>

 

 

配置完成後記得重啓Apache httpd

 

service httpd restart

 

 

相關文章
相關標籤/搜索