- 启用代理模块
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
- 配置VirtualHost
sudo vi /etc/apache2/sites-enabled/my.conf
配置内容如下:
<VirtualHost *:8085>
ServerName www.lsl.com
ServerAdmin webmaster@localhost
# 你的项目地址
DocumentRoot /home/user/Desktop/software/git/TEMP/wechat-resume/resume/resume-frontend/dist
<Directory /home/user/Desktop/software/git/TEMP/wechat-resume/resume/resume-frontend/dist>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ProxyPreserveHost On
ProxyPass /api http://172.20.60.24:9999
ProxyPassReverse /api http://172.20.60.24:9999
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- 重启服务
sudo service apache2 restart
- 测试
http://localhost:8085/api/test 对应即访问 http:172.20.60.24:9999/test