Nginx proxy server running in Docker container returns 504
I am trying to setup a docker network of two containers. One container holds a Wildfly application, and the other machine is an Nginx proxy server. The proxy server is just a placeholder for a load balancer used in a production environment. Therefore, the Nginx server simply forwards all requests to the wildfly server on :8080.
This setup works when I run the containers in the default bridge network, but I would like to use a user-defined network to mimic hostname resolution. But when I run the setup in a user-defined network, I can no longer reach the Wildfly application through the Nginx server, and I only get 504 timeout errors.
This is my nginx configuration file:
server
listen 80;
return 301 https://$host$request_uri;
server
listen 443;
server_name dev-reports.passkey.com;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/rpt.access.log;
location /
sub_filter '172.18.0.2' '127.0.0.2';
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;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://172.18.0.2:8080;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
And these are the scripts I use to run the Nginx server:
IP=127.0.0.3
docker run -d --name nginx-server -v ~/path/to/logs:/var/log/nginx --network user-network -p $IP:8443:443 nginx
And the Wildfly server:
IP=127.0.0.2
docker run -d --name wildfly-app --network user-network -v $1:/mnt/share -v $1/logs:/opt/wildfly/standalone/log/ -p $IP:9990:9990 -p $IP:80:8080 -p $IP:8787:8787 -p $IP:443:8443 -p $IP:1099:1099 -p $IP:1129:1129 -p $IP:1139:1139 -p $IP:8083:8083 -p $IP:8889:8889 wildfly-app
I run sudo ifconfig lo0 alias 127.0.0.* up
To open up 127.0.0.2 and 127.0.0.3
docker nginx networking wildfly http-status-code-504
add a comment |
I am trying to setup a docker network of two containers. One container holds a Wildfly application, and the other machine is an Nginx proxy server. The proxy server is just a placeholder for a load balancer used in a production environment. Therefore, the Nginx server simply forwards all requests to the wildfly server on :8080.
This setup works when I run the containers in the default bridge network, but I would like to use a user-defined network to mimic hostname resolution. But when I run the setup in a user-defined network, I can no longer reach the Wildfly application through the Nginx server, and I only get 504 timeout errors.
This is my nginx configuration file:
server
listen 80;
return 301 https://$host$request_uri;
server
listen 443;
server_name dev-reports.passkey.com;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/rpt.access.log;
location /
sub_filter '172.18.0.2' '127.0.0.2';
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;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://172.18.0.2:8080;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
And these are the scripts I use to run the Nginx server:
IP=127.0.0.3
docker run -d --name nginx-server -v ~/path/to/logs:/var/log/nginx --network user-network -p $IP:8443:443 nginx
And the Wildfly server:
IP=127.0.0.2
docker run -d --name wildfly-app --network user-network -v $1:/mnt/share -v $1/logs:/opt/wildfly/standalone/log/ -p $IP:9990:9990 -p $IP:80:8080 -p $IP:8787:8787 -p $IP:443:8443 -p $IP:1099:1099 -p $IP:1129:1129 -p $IP:1139:1139 -p $IP:8083:8083 -p $IP:8889:8889 wildfly-app
I run sudo ifconfig lo0 alias 127.0.0.* up
To open up 127.0.0.2 and 127.0.0.3
docker nginx networking wildfly http-status-code-504
add a comment |
I am trying to setup a docker network of two containers. One container holds a Wildfly application, and the other machine is an Nginx proxy server. The proxy server is just a placeholder for a load balancer used in a production environment. Therefore, the Nginx server simply forwards all requests to the wildfly server on :8080.
This setup works when I run the containers in the default bridge network, but I would like to use a user-defined network to mimic hostname resolution. But when I run the setup in a user-defined network, I can no longer reach the Wildfly application through the Nginx server, and I only get 504 timeout errors.
This is my nginx configuration file:
server
listen 80;
return 301 https://$host$request_uri;
server
listen 443;
server_name dev-reports.passkey.com;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/rpt.access.log;
location /
sub_filter '172.18.0.2' '127.0.0.2';
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;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://172.18.0.2:8080;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
And these are the scripts I use to run the Nginx server:
IP=127.0.0.3
docker run -d --name nginx-server -v ~/path/to/logs:/var/log/nginx --network user-network -p $IP:8443:443 nginx
And the Wildfly server:
IP=127.0.0.2
docker run -d --name wildfly-app --network user-network -v $1:/mnt/share -v $1/logs:/opt/wildfly/standalone/log/ -p $IP:9990:9990 -p $IP:80:8080 -p $IP:8787:8787 -p $IP:443:8443 -p $IP:1099:1099 -p $IP:1129:1129 -p $IP:1139:1139 -p $IP:8083:8083 -p $IP:8889:8889 wildfly-app
I run sudo ifconfig lo0 alias 127.0.0.* up
To open up 127.0.0.2 and 127.0.0.3
docker nginx networking wildfly http-status-code-504
I am trying to setup a docker network of two containers. One container holds a Wildfly application, and the other machine is an Nginx proxy server. The proxy server is just a placeholder for a load balancer used in a production environment. Therefore, the Nginx server simply forwards all requests to the wildfly server on :8080.
This setup works when I run the containers in the default bridge network, but I would like to use a user-defined network to mimic hostname resolution. But when I run the setup in a user-defined network, I can no longer reach the Wildfly application through the Nginx server, and I only get 504 timeout errors.
This is my nginx configuration file:
server
listen 80;
return 301 https://$host$request_uri;
server
listen 443;
server_name dev-reports.passkey.com;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/rpt.access.log;
location /
sub_filter '172.18.0.2' '127.0.0.2';
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;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://172.18.0.2:8080;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
And these are the scripts I use to run the Nginx server:
IP=127.0.0.3
docker run -d --name nginx-server -v ~/path/to/logs:/var/log/nginx --network user-network -p $IP:8443:443 nginx
And the Wildfly server:
IP=127.0.0.2
docker run -d --name wildfly-app --network user-network -v $1:/mnt/share -v $1/logs:/opt/wildfly/standalone/log/ -p $IP:9990:9990 -p $IP:80:8080 -p $IP:8787:8787 -p $IP:443:8443 -p $IP:1099:1099 -p $IP:1129:1129 -p $IP:1139:1139 -p $IP:8083:8083 -p $IP:8889:8889 wildfly-app
I run sudo ifconfig lo0 alias 127.0.0.* up
To open up 127.0.0.2 and 127.0.0.3
docker nginx networking wildfly http-status-code-504
docker nginx networking wildfly http-status-code-504
asked Nov 11 '18 at 23:02
Christian BakerChristian Baker
1592517
1592517
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254120%2fnginx-proxy-server-running-in-docker-container-returns-504%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254120%2fnginx-proxy-server-running-in-docker-container-returns-504%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown