0%

apache 代理转发

一、转发时需开启如下:

1
2
3
4
5
6
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html

参考链接

二、相关代码:

80端口转发其他多个项目端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/xunke
ErrorLog /etc/apache2/error.log
CustomLog /etc/apache2/access.log combined
#ProxyPassMatch /xunke/ http://localhost:8003/ # 匹配带有xunke的url 不适用
ProxyPass /xunke http://localhost:8003/
ProxyPassReverse /xunke http://localhost:8003/
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/topmps
ErrorLog /etc/apache2/error.log
CustomLog /etc/apache2/access.log combined
#ProxyPassMatch /topmps/ http://localhost:8002/
ProxyPass /topmps/ http://localhost:8002/
ProxyPassReverse /topmps/ http://localhost:8002/
</VirtualHost>

参考链接1
参考链接2

apache 监听多个端口

  • 目录:/etc/apache2/ports.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Listen 80
    Listen 8003
    Listen 8004

    <IfModule ssl_module>
    Listen 443
    </IfModule>

    <IfModule mod_gnutls.c>
    Listen 443
    </IfModule>
  • 目录:/etc/apache2/sites-available/000-default.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <VirtualHost *:8003>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/xunke
    ErrorLog /etc/apache2/error.log
    CustomLog /etc/apache2/access.log combined
    </VirtualHost>

    <VirtualHost *:8004>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/qibo
    ErrorLog /etc/apache2/error.log
    CustomLog /etc/apache2/access.log combined
    </VirtualHost>
------------- 本文结束 感谢您的阅读-------------