站点图标 陌路寒暄

ubuntu Apache 设置反向代理

首先需要用到proxy_module和proxy_http_module这两个模块,而通过apt安装的Apache默认是没有开启这两个模块的,可以通过下面两个命令开启:

shella2enmod proxy
a2enmod proxy_http

然后重启Apache,通过

shellapache2ctl -M | grep proxy

命令查看两个模块是否启用成功

shellproxy_module (shared)
proxy_http_module (shared)

然后像平常添加网站一样建立conf文件就好了


<VirtualHost *:80>
    ServerName example.com
    ProxyPass / http://127.0.0.1:port/
    ProxyPassReverse / http://127.0.0.1:port/
</VirtualHost>

 

退出移动版