Forwarding requests to Kestral from Apache
For a single web siteApache Configuration files are in the /etc/httpd/conf.d/ directory. Any files with the .conf extension are processed in alphabetical order in addition to the module configuration files in the /etc/httpd/conf.modules.d/ directory.
- Create a configuration file for your app.
Note that the example conf file below could be improved by using variables for the request type and log file names, and by specifying a domain.
<VirtualHost *:*> RequestHeader set X-Forwarded-Proto "http" </VirtualHost> <VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://127.0.0.1:5000/ ProxyPassReverse / http://127.0.0.1:5000/ ErrorLog /var/log/apache2/myapp-error.log CustomLog /var/log/apache2/myapp-access.log common </VirtualHost>
- ProxyPreserveHost - Instructs Apache mod_proxy, when acting as a reverse proxy, to preserve the original host header from the client browser when constructing the proxied request to send to the backend server.
- ProxyPass - Specifies the mapping of incoming requests to a backend server.
- ProxyPassReverse - Ensures that Location headers generated from the backend are modified to point to the reverse proxy, instead of back to itself.
- Restart Apache:
sudo systemctl restart httpd sudo systemctl enable httpd