You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NGINX and backend containers (JAVA) are managed through docker-compose.
They are all connected to the same bridged network.
When the JAVA container is restarted, the port exposed outside of Nginx cannot be accessed and an error 404 is displayed. In fact, the resource actually exists.
Nginx reverse proxy is requesting the wrong IP address, not the actual IP address of the current backend (JAVA) container.
The IP address of the Nginx reverse proxy is always obtained as the expired address last used by the JAVA container.
My stupid solution, restarting the JAVA container together with Nginx, is obviously not the best solution.
More:
The Ping command (ping java-05-server) in the Nginx container returns the correct IP address of the JAVA container.
Nginx Config:proxy_pass http://java-05-server:43021
Docker network custom creation (docker network create app-network).
docker-compose network specified to join the extended network(external: true).
Nginx log: [error] 22#22: *47 connect() failed (111: Connection refused) while connecting to upstream.
Experts, have you encountered similar problems, can you tell me your solution? Thank you!
The text was updated successfully, but these errors were encountered:
Nginx caches the DNS lookup; to make it look it up all the time, you can put it in a variable or adjust the TTL of the cache: https://serverfault.com/a/593003
Thank you! Based on the solution you provided, I tried it and the problem still exists.
Nginx config changed to
server {
...
resolver 127.0.0.11; #The IP address comes from the nameserver value of the Nginx container /etc/resolv.conf file
set $backend "http://java-05-server:43021";
proxy_pass $backend;
...
}
Nginx caches the DNS lookup; to make it look it up all the time, you can put it in a variable or adjust the TTL of the cache: https://serverfault.com/a/593003
Thank you! Based on the ideas you provided, I have successfully solved the problem.
NGINX and backend containers (JAVA) are managed through docker-compose.
They are all connected to the same bridged network.
When the JAVA container is restarted, the port exposed outside of Nginx cannot be accessed and an error 404 is displayed. In fact, the resource actually exists.
Nginx reverse proxy is requesting the wrong IP address, not the actual IP address of the current backend (JAVA) container.
The IP address of the Nginx reverse proxy is always obtained as the expired address last used by the JAVA container.
My stupid solution, restarting the JAVA container together with Nginx, is obviously not the best solution.
More:
The Ping command (ping java-05-server) in the Nginx container returns the correct IP address of the JAVA container.
Nginx Config:proxy_pass http://java-05-server:43021
Docker network custom creation (docker network create app-network).
docker-compose network specified to join the extended network(external: true).
Nginx log: [error] 22#22: *47 connect() failed (111: Connection refused) while connecting to upstream.
Experts, have you encountered similar problems, can you tell me your solution? Thank you!
The text was updated successfully, but these errors were encountered: