歡迎喜歡文章的朋友們自行轉錄,請在轉錄開頭註明出處與連結感謝各位的尊重與支持!^_^

2016年10月13日 星期四

UBUNTU 14.04 Apache2 設定Proxy至其他Port


1. 更新程式庫

aptitude    update
aptitude -y upgrade


2. 取得編譯工具

aptitude install -y build-essential


3. 安裝插件與關聯

aptitude install -y libapache2-mod-proxy-html libxml2-dev


4. 設定Apache

a2enmod
proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html


5. 新增Virtual Host設定檔

 <VirtualHost *:80>
    ProxyPreserveHost On

    # Servers to proxy the connection, or;
    # List of application servers:
    # Usage:
    # ProxyPass / http://[IP Addr.]:[port]/
    # ProxyPassReverse / http://[IP Addr.]:[port]/
    # Example: 
    ProxyPass / http://0.0.0.0:8080/
    ProxyPassReverse / http://0.0.0.0:8080/

    ServerName localhost
</VirtualHost>


6. 重開Apache

service apache2 restart

7. 出現Notice提示要多裝mod_xml2enc


[proxy_html:notice] [pid 26434] AH01425: I18n support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII characters in proxied pages are likely to display incorrectly.

sudo apt-get install apache2-prefork-dev libxml2 libxml2-dev apache2-dev
mkdir ~/modbuild/ && cd ~/modbuild/
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.c
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.h
sudo apxs2 -aic -I/usr/include/libxml2 ./mod_xml2enc.c
cd ~
sudo rm -rfd ~/modbuild/
sudo service apache2 restart




參考文件:

  • https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension


  • https://gist.github.com/oskarnrk/1c9e436408aacf7671c3
Related Posts Plugin for WordPress, Blogger...