Background
I have a remote server on which an R API service is running by the use of Plumber. It is fully operational in the sense that I can call my service externally.
I am using an Ubuntu/Nginx reverse proxy setup. The Plumber service is listening to port 1163. I have subsequently implemented the following Nginx rerouting such that the API listens to https://server.net/API/:
location /API/ {
proxy_pass http://localhost:1163/;
proxy_redirect http://localhost:1163/ $scheme://$host/;
}
This is working fine. Now, by default, the Swagger UI listens to
http://127.0.0.1:1163/__swagger__/
which, owing to the config above, means that I can successfully access the Swagger UI at
https://server.net/API/__swagger__/
Issue
I want to configure Nginx such that the Swagger UI listens to https://server.net/API/documentation/. I have attempted the following nested Nginx configuration:
location /API/ {
proxy_pass http://localhost:1163/;
proxy_redirect http://localhost:1163/ $scheme://$host/;
location /API/documentation/ {
proxy_pass http://localhost:1163/__swagger__/;
proxy_redirect http://localhost:1163/__swagger__/ $scheme://$host/;
}
}
Now, while entering the desirable URL https://server.net/API/documentation/ into my browser, I retrieve the Swagger interface, however it returns the following error code:
Evidently, the incorrect swagger URL has been parsed during the Nginx redirection. This is clear considering that the url should state
https://server.net/API/swagger.json?schemes=https&host=server.net&path=/API/
instead of
http://petstore.swagger.io/v2/swagger.json
How can I ensure that the correct URL is parsed to the Swagger UI during the Nginx redirection? All the best, J.