Reverse Proxy
HTTP Headers
To allow for the use of the application behind a reverse proxy the following headers must be sent in requests:
Header Name | Description |
---|---|
| The name of the server the request was sent to |
| The IP of the client making requests to the application |
| A comma separated list of all clients previously passed through when making the request |
| The protocol that was used to connect to the proxy (HTTP or HTTPS) |
This will have to be configured in the reverse proxy itself, no configuration in the application is required.
An example of how this can be done in nginx is shown below:
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
It is possible view the HTTP request headers that are being received by the application via the Administrator UI. To navigate to this page first click on “Debug Views”:
Then on the provided list of functions select “Show request headers”:
The application will then show a list of the HTTP request headers and their values that were received by the application.
Server context path
If the application is configured to use a context path in the URL, it is strongly advised that the reverse proxy is configured to forward requests using the same value. If this is not done then depending on the server configuration the application may not resolve correctly.
For example if the application’s conf.yml is configured as follows:
server:
servlet:
contextPath: '/api'
Then the reverse proxy is configured to forward request to the application using the ‘/api’ path. For the above example the NGINX configuration needs to be adjusted as follows:
location /api {
proxy_pass http://127.0.0.1:8080/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}