要在Apache中使用ProxyPass保留端口,你可以使用以下代码示例:
sudo a2enmod proxy
sudo a2enmod proxy_http
ServerName example.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
上述代码中,将所有来自example.com的请求代理到本地的8080端口。ProxyPass指令指定了要代理的目标URL,ProxyPassReverse指令用于重写响应中的URL。
sudo service apache2 restart
现在,当访问example.com时,Apache会将请求代理到本地的8080端口上。你可以根据你的实际需求修改上述代码段中的ServerName和代理的目标URL。