wiki:proxying_dns_name_local_service
Table of Contents
Proxying DNS name to local service
Enable apache modules first
a2enmod proxy proxy_http
vhost configuration example for service running on port 8080
Part to be added:
<VirtualHost *:80> ServerName sub.example.com ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ </VirtualHost>
Note: Put above in ssl configuration when redirecting to ssl ports. Note: If the first argument in ProxyPass directives ends with a trailing /, the second argument should also end with a trailing /, and vice versa. Otherwise, the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.
- ProxyPreserveHost makes Apache pass the original Host header to the backend server. This is useful, as it makes the backend server aware of the address used to access the application.
- ProxyPass is the main proxy configuration directive. In this case, it specifies that everything under the root URL (/) should be mapped to the backend server at the given address. For example, if Apache gets a request for /example, it will connect to http://your_backend_server/example and return the response to the original client.
- ProxyPassReverse should have the same configuration as ProxyPass. It tells Apache to modify the response headers from backend server. This makes sure that if the backend server returns a location redirect header, the client’s browser will be redirected to the proxy address and not the backend server address, which would not work as intended.
Restart apache2
systemctl restart apache2
Tested on
See also
References
wiki/proxying_dns_name_local_service.txt · Last modified: 2022/02/28 16:11 by antisa