I have an issue with my Spring Boot API, which I use in combination with Docker and Nginx as a reverse proxy.
At the moment I am setting up a website together with a REST webservice. The webserver and the REST webservice (Spring Boot) are running in two different Docker containers. In order to provide HTTPS (encryption) I use NGINX as a reverse proxy (which is also running as a Docker-Container).
Now I am using the following setup in my nginx.conf
to enable outside access to my Spring API.
upstream spring-backend {
server spring:8081;
}
# ... some other configuration stuff
server {
listen 7332;
ssl on;
# ... ssl-config
# all other traffic
location / {
# Specify the fields added/redefined to the request header passed to the proxied server.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Timeout for reading a response from the proxied server.
proxy_read_timeout 3600; # keep open even without any transmission
proxy_pass http://spring-backend;
}
}
While this works well, I am encountering the issue that API URIs Spring creates for the created entities look as follows: http://spring-backend/{entity}/{id}
.
This apparently cannot be accessed from another computer consuming the website and it's associated webservice. Instead I would need the entries to be https://{the-url-of-the-webserive}:7332/{entity}/{id}
.
However I am not sure whether it is possible to get this resolution from the name-resolution NGINX uses (as it should replace server-backend
with spring:8081
) and the one of Docker (should replace at least the spring
part with the actual adress).