Configure Apache reverse proxy
- Open the configuration file httpd.conf
- Open the proxy_http_module and proxy_module modules and delete the # sign
#LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_http_module modules/mod_proxy_http.so
- Detailed proxy configuration
You can configure a reverse proxy for a virtual host separately, so that different virtual hosts can be proxied to different servers
- Open the auxiliary configuration, delete the # sign
#Include conf/extra/httpd-vhosts.conf
- Configure virtual host
Fill in the following two lines of code
ProxyRequests Off ProxyPass /api http://api.aaaa.com
Pay attention to spaces, all codes
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "E:/www/xxxxx" ServerName xxxxx.com ServerAlias www.xxxxx.com ErrorLog "logs/dummy-host.studyit.com-error.log " CustomLog "logs/dummy-host.studyit.com-access.log" common ProxyRequests Off # Accessing /api is equivalent to accessing http://api.aaaa.com # In this way, all requests will be proxied to http: //api.aaaa.com ProxyPass /api http://api.aaaa.com #Here http://api.aaaa.com is my server, in the company it should be based on the actual # /api is not fixed Yes, you can adjust it yourself</VirtualHost>