Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4144

How to fix Bad Gateway error after API calls of app running in Docker Container (nginx server, windows)?

$
0
0

I have just run an app consisting of MongoDB, a REST API and a web app running with nginx with Docker (docker-compose, webapp is at port 8888:80, but the following problem also occured on 80:80). Without Docker the communication between all those pieces worked perfectly, now every time, when requests to the API are made, the response is "Bad Gateway (502)". I guess it has to do with my nginx.conf or Dockerfile of the webapp, but I'm not sure. Attached is the code.Does somebody have a solution? For interest I'm on windows.

EDIT:I now changed "localhost:8080" to "service:8080" cause the service is basically my API, but now I get an internal server error (500).

My nginx.conf:

user  nginx;worker_processes 1;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        run/nginx.pid;events {    worker_connections 1024;}http {    include       mime.types;    default_type application/octet-stream;    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '    #                  '$status $body_bytes_sent "$http_referer" '    #                  '"$http_user_agent" "$http_x_forwarded_for"';    #access_log  logs/access.log  main;    sendfile on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout 65;    #gzip  on;    server {        listen 80;        server_name localhost;        #charset koi8-r;        #access_log  logs/host.access.log  main;        location / {            include mime.types;            root html;            index start.html;        }        #error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        #error_page 500 502 503 504 /50x.html;        #location = /50x.html {        #    root html;        #}        location /api {            proxy_pass http://localhost:8080;        }    }}

My Dockerfile:

FROM nginx:1.26.1COPY ./html /etc/nginx/htmlCOPY ./conf/nginx.conf /etc/nginx/nginx.confEXPOSE 80

Viewing all articles
Browse latest Browse all 4144

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>