一、转发时需开启如下:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
参考链接
二、相关代码:
80端口转发其他多个项目端口
<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
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
<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>
网友评论