coder
asked on
I get bad gateway error when running the application from the docker
Hi Experts,
I get a bad gateway when running the web application from docker.
I had installed nginx inside the docker container.
for eg,
docker gateway is 1.2.3.4
public ip is 4.3.2.1
I create the environment for the docker container
I had run the following commands to run the docker container
docker run --name ntdl -d --restart always ${ntdl_environment[@]} f27af16c9ed6
to go inside bash shell for the docker container i had run the follow command from command prompt
docker exec -it ntdl /bin/bash
when I run gateway ip for elasticsearch it is running fine inside docker
I get the following results it is working fine
root@16a1d7df5399:/home/nt dl/code# curl -XGET 1.2.3.4:9200
{
"name" : "C****D",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "FG4Sgll3Rau***6nQ",
"version" : {
"number" : "5.6.4",
"build_hash" : "8bbedf5",
"build_date" : "2017-10-31T18:55:38.105Z" ,
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
I had checked nginx status inside docker it is working fine.
root@16a1d7df5399:/home/nt dl/code# service nginx status
* nginx is running
curl -XGET 'localhost' inside the docker gets the following below error
When I run
curl gateway ip provides the bad gateway inside docker.
When I try the public ip from browser on windows machine
http://public-ip/
http://4.3.2.1/
502 bad gateway
Dockerfile has the following contents
start has npm run start-prod
in package.json
please help me in resolving this issue.
With Many thanks,
Bharath AK
I get a bad gateway when running the web application from docker.
I had installed nginx inside the docker container.
for eg,
docker gateway is 1.2.3.4
public ip is 4.3.2.1
I create the environment for the docker container
declare -a ntdl_environment=( -e ES_CONNECTION=1.2.3.4:9200 -e DATABASE=postgres://user:****@1.2.3.4/ntdl -e LOCAL_URL_PREFIX==https://ntest-dev.s3.amazonaws.com -e IIIF_SERVER=http://4.3.2.1/iiif -e FACEBOOK_APP_ID=000000 -e CLOUD_WATCH=true -e AWS_ACCESS_KEY_ID=akz44 -e AWS_SECRET_ACCESS_KEY=******** -e AWS_DEFAULT_REGION=ap-abct-2 -e S3_BUCKET=abc-test-dev -e GENERIC_SERVER_NAME=http://4.3.2.1 -e SEARCH_PATH=/ -e SEARCH_DOMAIN=http://4.3.2.1 -e HANDLE_SITEMAP_PATH=https://s3-test.amazonaws.com/ntest/sitemap/sitemap.txt.gz -e DEBUG=true)
I had run the following commands to run the docker container
docker run --name ntdl -d --restart always ${ntdl_environment[@]} f27af16c9ed6
to go inside bash shell for the docker container i had run the follow command from command prompt
docker exec -it ntdl /bin/bash
when I run gateway ip for elasticsearch it is running fine inside docker
I get the following results it is working fine
root@16a1d7df5399:/home/nt
{
"name" : "C****D",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "FG4Sgll3Rau***6nQ",
"version" : {
"number" : "5.6.4",
"build_hash" : "8bbedf5",
"build_date" : "2017-10-31T18:55:38.105Z"
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
I had checked nginx status inside docker it is working fine.
root@16a1d7df5399:/home/nt
* nginx is running
curl -XGET 'localhost' inside the docker gets the following below error
RenderServerError at /
Could not connect to render server at http://127.0.0.1:9009/render
Request Method: GET
Request URL: http://localhost/
Django Version: 1.11.1
Exception Type: RenderServerError
Exception Value:
Could not connect to render server at http://127.0.0.1:9009/render
Exception Location: /usr/local/lib/python3.6/dist-packages/react/render_server.py in render, line 56
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.6.2
Python Path:
['.',
'',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages']
Server time: Tue, 12 Feb 2019 08:34:51 +0930
When I run
curl gateway ip provides the bad gateway inside docker.
root@16a1d7df5399:/home/ntdl/code# curl -XGET '1.2.3.4'
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>
When I try the public ip from browser on windows machine
http://public-ip/
http://4.3.2.1/
502 bad gateway
Dockerfile has the following contents
FROM ubuntu:16.04
ENV PRODUCTION true
RUN rm -f /etc/nginx
RUN apt-get update -y && apt-get install -y curl
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository -y ppa:fkrull/deadsnakes
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get update -y && apt-get install -y \
git \
libpq-dev \
python3.6 \
python3.6-dev \
nginx \
sqlite3 \
nodejs \
build-essential \
curl \
libpcre3 libpcre3-dev
RUN rm -f /usr/bin/python3
RUN ln -s /usr/bin/python3.6 /usr/bin/python3
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
#RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN mkdir -p /etc/nginx/sites-available/
#COPY build/docker/nginx-app.conf /etc/nginx/sites-available/default
COPY build/docker/nginx-app.conf /etc/nginx/sites-enabled/default
COPY build/docker/nginx.conf /etc/nginx/nginx.conf
COPY build/docker/start /usr/bin/
WORKDIR /home/ntdl
COPY build/generated/www static
COPY . code
# TODO: Remove media for production
RUN mv code/media .
ADD build/generated/bundles/* code/
WORKDIR /home/ntdl/code
RUN chmod 755 /home/ntdl/code
RUN chown -R www-data:www-data /home/ntdl/code
COPY build/docker/uwsgi_params .
COPY build/docker/uwsgi.ini .
RUN pip3 install --no-cache-dir uwsgi
RUN pip3 install --no-cache-dir -r requirements.txt
RUN npm install -g yarn
RUN yarn install
EXPOSE 80
CMD ["start"]
start has npm run start-prod
in package.json
"start-prod": "concurrently --no-color \"uwsgi --ini /home/ntdl/code/uwsgi.ini\" \"nginx\" \"npm run render-prod\"",
"render-prod": "babel-node node/react-render.jsx",
please help me in resolving this issue.
With Many thanks,
Bharath AK
ASKER
Hi dfke,
Thanks for your response.
I get the following results. with gateway ipaddress 172.17.0.1 I get the following results.
I had attached out.html for reference.
Please help me in resolving this issue and throw some light on it.
With Many thanks,
Bharath AK
out.html
Thanks for your response.
I get the following results. with gateway ipaddress 172.17.0.1 I get the following results.
root@ddbdeb2ce68c:/home/ntdl/code# curl -XGET 'localhost:9200'
curl: (7) Failed to connect to localhost port 9200: Connection refused
root@ddbdeb2ce68c:/home/ntdl/code# curl -XGET '172.17.0.1:9200'
{
"name" : "CDQuQwD",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "FG4Sgll3Rau4sipbkon6nQ",
"version" : {
"number" : "5.6.4",
"build_hash" : "8bbedf5",
"build_date" : "2017-10-31T18:55:38.105Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
root@ddbdeb2ce68c:/home/ntdl/code# curl -XGET '172.17.0.1:80'
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>
root@ddbdeb2ce68c:/home/ntdl/code# curl -XGET 'localhost:80' > out.html
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19344 100 19344 0 0 29402 0 --:--:-- --:--:-- --:--:-- 29398
root@ddbdeb2ce68c:/home/ntdl/code# exit
exit
root@ip-10-252-14-11:/home/ubuntu# docker cp ntdl:\home\ntdl\code\out.html .
Error response from daemon: lstat /var/lib/docker/aufs/mnt/67efbb5ef87c405e8ba6b4a52dcc49ccfe6bbe2b564626f425d39a364b3d5599/homentdlcodeout.html: no such file or directory
root@ip-10-252-14-11:/home/ubuntu# docker cp ntdl:/home/ntdl/code/out.html .
I had attached out.html for reference.
Please help me in resolving this issue and throw some light on it.
With Many thanks,
Bharath AK
out.html
ASKER
Hi Dfke,
Do you need any other information? Please help me in resolving this issue.
Thanks,
Bharath AK
Do you need any other information? Please help me in resolving this issue.
Thanks,
Bharath AK
Your out.html file shows no error, so if you still have some other problem, place an update about the problem you're seeing.
Note: IP 172.17.0.1 won't work unless you've plumbed this through some sort of iptables rule or bridge or somehow.
Use 127.0.0.1 or look at the output of netstat -pluten to determine address your docker container is listening on.
Note: IP 172.17.0.1 won't work unless you've plumbed this through some sort of iptables rule or bridge or somehow.
Use 127.0.0.1 or look at the output of netstat -pluten to determine address your docker container is listening on.
Hi,
It could be that the http-server already binds to 127.0.0.1 itself.
Try and figure out the current ip adress first:
It could be that the http-server already binds to 127.0.0.1 itself.
Try and figure out the current ip adress first:
ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'
Cheers
ASKER
Hi Experts,
Thanks for your response. I get the followng results, when I run from the ubuntu machine
if you need any other information, please get back to me.
WithMany thanks,
Bharath AK
Thanks for your response. I get the followng results, when I run from the ubuntu machine
root@ip-10-252-14-11:/home/ubuntu/workarea/ntdl-2# docker network inspect bridge
[
{
"Name": "bridge",
"Id": "734de3a47036fc36d8e9a82e026e6781248722e75ce7fe8fcd080426f9088e02",
"Created": "2019-02-05T01:34:19.069113665Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"1dcdc35e5b77bb6bcd5fac6207bb276df0934b38fd5c6508b42817e77c8b664d": {
"Name": "trove_push",
"EndpointID": "20295ecc6c0c06d14d050f804fe007fcc2c76896100add07fa790c15d7fd6476",
"MacAddress": "02:42:ac:11:00:05",
"IPv4Address": "172.17.0.5/16",
"IPv6Address": ""
},
"8832318564fb39762fab38aee5c6012ed85ee1972b607260af071528ac063a22": {
"Name": "trove_process",
"EndpointID": "222d65e7975e697d62fc29e7d80858ecdcafefbf06548813a87c3bb07e410767",
"MacAddress": "02:42:ac:11:00:04",
"IPv4Address": "172.17.0.4/16",
"IPv6Address": ""
},
"905232ed4ce6fe466e252ce9dd9e39439950ea350846a65fe0506c388b24b727": {
"Name": "iiif",
"EndpointID": "d47c793b3a57eade1d533eda26307c6f330fbd31f2ac250bb0237faadb6bf4dc",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
},
"a251c24a7a9f0f59bc0a2e8d8ffa9b70c819c089f0ca05670b0c30c27d320a12": {
"Name": "trove_review",
"EndpointID": "ddb8310540679e4f514e4565f21737af875cd4ee3a99be9415975de95bda5adb",
"MacAddress": "02:42:ac:11:00:06",
"IPv4Address": "172.17.0.6/16",
"IPv6Address": ""
},
"e9043bc80746ee63f705010bd4344460e80c02f888307658bddfb7081521010c": {
"Name": "trove_pull",
"EndpointID": "fffa2fbf98f28f56d71def189b7182ea714d3a5b589f2026179aa39419ec4906",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
root@ip-10-252-14-11:/home/ubuntu/workarea/ntdl-2# netstat -pluten
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 18524 1367/nginx -g daemo
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 15969 1290/sshd
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 112 398412 890/postgres
tcp6 0 0 127.0.0.1:9998 :::* LISTEN 0 858274 10270/java
tcp6 0 0 :::9200 :::* LISTEN 113 45319 13294/java
tcp6 0 0 :::9300 :::* LISTEN 113 45276 13294/java
tcp6 0 0 :::22 :::* LISTEN 0 15971 1290/sshd
tcp6 0 0 :::5432 :::* LISTEN 112 398413 890/postgres
tcp6 0 0 :::8009 :::* LISTEN 0 459192 11018/docker-proxy
udp 0 0 0.0.0.0:68 0.0.0.0:* 0 10176 1090/dhclient
root@ip-10-252-14-11:/home/ubuntu/workarea/ntdl-2# ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'
en0: error fetching interface information: Device not found
if you need any other information, please get back to me.
WithMany thanks,
Bharath AK
There's only so much you can determine by running host level commands.
You may have to add sshd/bash plumbing to your container setup so you can ssh into the container for better debugging.
You can also attempt to chroot into your container rootfs. This might work. You'll still require adding the bash package to your container config.
You may have to add sshd/bash plumbing to your container setup so you can ssh into the container for better debugging.
You can also attempt to chroot into your container rootfs. This might work. You'll still require adding the bash package to your container config.
Tip: Consideration
You're using sqlite3 in your container setup.
I normally use LXD, so all data in LXD containers is persistent.
As I understand, when docker data is ephemeral, so when containers stop all related data is destroyed.
Be sure you research this + if any data persistence is required, you take appropriate steps to capture/retain data, as required.
You're using sqlite3 in your container setup.
I normally use LXD, so all data in LXD containers is persistent.
As I understand, when docker data is ephemeral, so when containers stop all related data is destroyed.
Be sure you research this + if any data persistence is required, you take appropriate steps to capture/retain data, as required.
ASKER
Hi David,
I am using PostgreSQL for persistence. and 172.17.0.1 is the docker gateway. do you need any other information.
do you want any other things i want try.
"You may have to add sshd/bash plumbing to your container setup so you can ssh into the container for better debugging.
You can also attempt to chroot into your container rootfs. This might work. You'll still require adding the bash package to your container config. " - how to do this?
Please help me how to fix the badgateway error.
many thanks,
Bharath AK
I am using PostgreSQL for persistence. and 172.17.0.1 is the docker gateway. do you need any other information.
do you want any other things i want try.
"You may have to add sshd/bash plumbing to your container setup so you can ssh into the container for better debugging.
You can also attempt to chroot into your container rootfs. This might work. You'll still require adding the bash package to your container config. " - how to do this?
Please help me how to fix the badgateway error.
many thanks,
Bharath AK
Focusing on gateway error...
What's odd is this.
1) Looks like NGINX is actually running + accessible.
2) To test + verify this, just drop a test.txt file into DocumentRoot directory NGINX is using to serve content.
3) Normally the dreaded 502 occurs, when NGINX can't talk to some other process, which is normally Apache or FPM PHP.
4) In your container config, no packages exist for any other process.
5) Also, you may think you're using PostgreSQL...
This is correct if PostgreSQL is running outside your container.
This is incorrect if you imagine PostgreSQL is running inside your container... because there are no PostgreSQL packages installed in the container config.
What's odd is this.
1) Looks like NGINX is actually running + accessible.
2) To test + verify this, just drop a test.txt file into DocumentRoot directory NGINX is using to serve content.
3) Normally the dreaded 502 occurs, when NGINX can't talk to some other process, which is normally Apache or FPM PHP.
4) In your container config, no packages exist for any other process.
5) Also, you may think you're using PostgreSQL...
This is correct if PostgreSQL is running outside your container.
This is incorrect if you imagine PostgreSQL is running inside your container... because there are no PostgreSQL packages installed in the container config.
Maybe describe the entire code stack you expect to be running inside your container (Webserver + database(s) + language interpreters).
Also describe type of work container is expected to perform.
Also describe what data is generated during container execution + how data persists across the container, so specifically for persistent data, you'll plumb in access to some host level database where persistent data will live.
Also describe type of work container is expected to perform.
Also describe what data is generated during container execution + how data persists across the container, so specifically for persistent data, you'll plumb in access to some host level database where persistent data will live.
ASKER
Hi David,
Thanks for your response.
I have a demo machine which is working condition. and the settings are as below on the demo machine.
demo machine settings
on the dev machine if I run
docker run --name ntdl -d --restart always ${ntdl_environment[@]} -p 8008:80 b19ab9cf4f46
I had missed port 8008:80 mapping on the docker run command and after including the port 8008 I get the following results
I get the following results on the browser when I try http://54.253.102.154/
I get this render error. do you think I have to open port 9009 on any place? Please get back to me regarding this.
secondly, to run the application without any containers I run with npm run command with port 8000 opened on the server application and it is working fine on port 8000
I run npm run runapp8000 from the command prompt
I get the following results from the command prompt and it runs properly.
see the results of the command prompt log
you can note the render server is listening at http://0.0.0.0:9009
I get this render server error when I run from the docker command.
the application is running fine from the npm run command I had configured the render server to run on 8000 port.
npm run runapp8000 value in package.json is as follows
"runapp8000": "concurrently --no-color \"npm run pack \" \"npm run render-prod\" \"npm run django8000\"",
application is running properly on port 8000
from inside the docker container ntdl which has now render server error Please see the below observations.
Now the only problem I have the render server error. Please help me in fixing the render server
With Many thanks,
Bharath AK
gateway-out.html
localhost-out.html
Thanks for your response.
I have a demo machine which is working condition. and the settings are as below on the demo machine.
demo machine settings
root@ip-10-7-17-197:/home/ubuntu# netstat -pluten
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 2664771 23278/nginx -g daem
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 13330542 28134/sshd
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 112 760165 24202/postgres
tcp6 0 0 :::8008 :::* LISTEN 0 2791190 5118/docker-proxy
tcp6 0 0 :::8009 :::* LISTEN 0 7709483 9030/docker-proxy
tcp6 0 0 :::8010 :::* LISTEN 0 19983 2568/docker-proxy
tcp6 0 0 172.17.0.1:9200 :::* LISTEN 113 2612356 4542/java
tcp6 0 0 172.17.0.1:9300 :::* LISTEN 113 2610418 4542/java
tcp6 0 0 :::22 :::* LISTEN 0 13330544 28134/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 0 2649 1132/dhclient
on the dev machine if I run
docker run --name ntdl -d --restart always ${ntdl_environment[@]} -p 8008:80 b19ab9cf4f46
I had missed port 8008:80 mapping on the docker run command and after including the port 8008 I get the following results
I get the following results on the browser when I try http://54.253.102.154/
RenderServerError at /
Could not connect to render server at http://127.0.0.1:9009/render
Request Method: GET
Request URL: http://127.0.0.1:8008/
Django Version: 1.11.1
Exception Type: RenderServerError
Exception Value:
Could not connect to render server at http://127.0.0.1:9009/render
Exception Location: /usr/local/lib/python3.6/dist-packages/react/render_server.py in render, line 56
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.6.2
Python Path:
['.',
'',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages']
Server time: Sun, 17 Feb 2019 22:34:13 +0930
I get this render error. do you think I have to open port 9009 on any place? Please get back to me regarding this.
secondly, to run the application without any containers I run with npm run command with port 8000 opened on the server application and it is working fine on port 8000
I run npm run runapp8000 from the command prompt
I get the following results from the command prompt and it runs properly.
see the results of the command prompt log
root@ip-10-252-14-11:/home/ubuntu/workarea/ntdl-2# npm run runapp8000
> ntdl@1.0.2 runapp8000 /home/ubuntu/workarea/ntdl-2
> concurrently --no-color "npm run pack " "npm run render-prod" "npm run django8000"
[0]
[0] > ntdl@1.0.2 pack /home/ubuntu/workarea/ntdl-2
[0] > webpack --watch --config node/webpack/webpack.config.js
[0]
[2]
[2] > ntdl@1.0.2 django8000 /home/ubuntu/workarea/ntdl-2
[2] > python3 manage.py runserver 0.0.0.0:8000
[2]
[1]
[1] > ntdl@1.0.2 render-prod /home/ubuntu/workarea/ntdl-2
[1] > babel-node node/react-render.jsx
[1]
[0]
[0] Webpack is watching the files...
[0]
[1] React render server listening at http://0.0.0.0:9009
[0] Hash: c912a890e10466d4aa9b
[0] Version: webpack 3.11.0
[0] Time: 11224ms
[0] Asset Size Chunks Chunk Names
[0] 0-ac84f4b80842a590740f.js 1.54 MB 0 [emitted] [big]
[0] search-448ad83a68b9110664a1.js 4.02 MB 1 [emitted] [big] search
[0] base-15ab873954ef6c912e9b.js 286 kB 2 [emitted] [big] base
[0] [18] (webpack)/buildin/global.js 509 bytes {1} {2} [built]
[0] [55] ./search/static/search/actions/index.js 3.94 kB {1} [built]
[0] [223] ./search/static/search/advanced-facets.jsx 16.5 kB {1} [built]
[0] [224] ./search/static/search/external-link.jsx 6.42 kB {1} [built]
[0] [338] ./search/static/search/theme.js 514 bytes {1} [built]
[0] [386] ./search/static/search/search.jsx 3.27 kB {1} [built]
[0] [536] ./search/static/search/app.jsx 11.7 kB {1} [built]
[0] [537] ./search/static/search/results.jsx 16 kB {1} [built]
[0] [725] ./search/static/search/search-options.jsx 12.4 kB {1} [built]
[0] [726] ./search/static/search/reducers/index.js 728 bytes {1} [built]
[0] [727] ./search/static/search/reducers/search.js 7.08 kB {1} [built]
[0] [728] ./search/static/search/reducers/advancedFacets.js 4.4 kB {1} [built]
[0] [729] ./search/static/search/reducers/viewer.js 5.08 kB {1} [built]
[0] [731] ./static/core/common.js 4.28 kB {2} [built]
[0] [934] ./static/style/style.js 9.82 kB {2} [built]
[0] + 922 hidden modules
you can note the render server is listening at http://0.0.0.0:9009
I get this render server error when I run from the docker command.
the application is running fine from the npm run command I had configured the render server to run on 8000 port.
npm run runapp8000 value in package.json is as follows
"runapp8000": "concurrently --no-color \"npm run pack \" \"npm run render-prod\" \"npm run django8000\"",
application is running properly on port 8000
from inside the docker container ntdl which has now render server error Please see the below observations.
root@ip-10-252-14-11:/home/ubuntu/workarea/ntdl-2# docker exec -it ntdl /bin/bash
root@a7762b799f7a:/home/ntdl# curl -XGET '172.17.0.1' > gateway-out.html
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 200k 100 200k 0 0 1293k 0 --:--:-- --:--:-- --:--:-- 1299k
root@a7762b799f7a:/home/ntdl# curl -XGET 'localhost' > localhost-out.html
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 88009 0 88009 0 0 245k 0 --:--:-- --:--:-- --:--:-- 245k
root@ef6007406024:/var/log/nginx# cat access.log
172.17.0.1 - - [17/Feb/2019:13:04:13 +0000] "GET / HTTP/1.0" 500 22844 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36"
127.0.0.1 - - [17/Feb/2019:13:05:04 +0000] "GET / HTTP/1.1" 500 213858 "-" "curl/7.47.0"
172.17.0.1 - - [17/Feb/2019:13:05:27 +0000] "GET / HTTP/1.0" 500 204925 "-" "curl/7.47.0"
root@ef6007406024:/var/log/nginx# cat error.log
root@ef6007406024:/var/log/nginx#
I had attached both the HTML for your reference.(localhost and gateway html) Please see both the HTML files to get clear clarity.Now the only problem I have the render server error. Please help me in fixing the render server
With Many thanks,
Bharath AK
gateway-out.html
localhost-out.html
You're still missing some sort of backend in your Docker config file.
There's no Apache or PHP, so you will always get a bad gateway error, unless you specifically have an index.html file.
Best to do the test I suggested, place a foo.txt file in your NGINX DocumentRoot + see if the file serves correctly.
Tip: Always get .txt + .html files serving first, before attempting to debug NGINX errors.
There's no Apache or PHP, so you will always get a bad gateway error, unless you specifically have an index.html file.
Best to do the test I suggested, place a foo.txt file in your NGINX DocumentRoot + see if the file serves correctly.
Tip: Always get .txt + .html files serving first, before attempting to debug NGINX errors.
ASKER
Hi David,
Thanks for your response.
Bad gateway error is resolved after including the docker proxy port 8008:80 while running the container. When I run from gateway or from the localhost now I get the same set of errors render server error. you can see from both the attachments. Please help me in resolving this error.
With Many thanks,
Bharath AK
Thanks for your response.
Bad gateway error is resolved after including the docker proxy port 8008:80 while running the container. When I run from gateway or from the localhost now I get the same set of errors render server error. you can see from both the attachments. Please help me in resolving this error.
With Many thanks,
Bharath AK
ASKER
Hi David,
When I change the port in the server(render server) to 80 I get Error: listen EADDRINUSE 0.0.0.0:80, it is running in port 9009, When the run the same thing as a application with npm run "babel-node node/react-render.jsx" it is running in 9009 port application and is running properly on any browser. whereas when I run from docker container it is throwing render server error How to solve this render server error when I run from a docker container. Please help me in resolving this.
with many thanks,
Bharath AK
When I change the port in the server(render server) to 80 I get Error: listen EADDRINUSE 0.0.0.0:80, it is running in port 9009, When the run the same thing as a application with npm run "babel-node node/react-render.jsx" it is running in 9009 port application and is running properly on any browser. whereas when I run from docker container it is throwing render server error How to solve this render server error when I run from a docker container. Please help me in resolving this.
with many thanks,
Bharath AK
ASKER
Hi David,
Do you need any other information? Do you want me to try anything? Please get back to me.
With Many thanks,
Bharath AK
Do you need any other information? Do you want me to try anything? Please get back to me.
With Many thanks,
Bharath AK
Unsure how gateway error resolves when you use port 8008:80, as this suggests something is running on port 8008.
Your best option is to install sshd + shell into your container + see what exactly is occurring.
Better to use ssh + know, than guess.
Your best option is to install sshd + shell into your container + see what exactly is occurring.
Better to use ssh + know, than guess.
ASKER
Hi David,
Thanks for your response.
In nginx conf
hence setting this in docker proxy running on 8008:80 makes this to resolve. Could you please suggest a solution for node server application running on port 9009. the render server error. When I change the server to use port 80 instead of 9009 I get Error: listen EADDRINUSE 0.0.0.0:80, it is a server running on 9009. Please help me in resolving this issue.
With many thanks,
Bharath AK
Thanks for your response.
In nginx conf
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8008;
}
}
I have this settings. hence setting this in docker proxy running on 8008:80 makes this to resolve. Could you please suggest a solution for node server application running on port 9009. the render server error. When I change the server to use port 80 instead of 9009 I get Error: listen EADDRINUSE 0.0.0.0:80, it is a server running on 9009. Please help me in resolving this issue.
With many thanks,
Bharath AK
ASKER
Hi David,
Can I raise the render server error as a new question as the bad gateway error is resolved? or let this to be part of this question. Please get back to me.
With Thanks,
Bharath AK
Can I raise the render server error as a new question as the bad gateway error is resolved? or let this to be part of this question. Please get back to me.
With Thanks,
Bharath AK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your help and suggestions.
What's the output of:
Open in new window
Cheers