NGINX reverse proxy not working to other docker containerDifference between proxy server and reverse proxy serverwhat's wrong with this configuration for nginx as reverse proxy for node.js?From inside of a Docker container, how do I connect to the localhost of the machine?Nginx and php-fpm docker composePeriodic drop in throughput of nginx reverse proxy, what can it be?Nginx as reverse proxy for docker containersDocker and NGINX - host not found in upstream when building with docker-composeDocker issue with nginx reverse proxying to golang serverHow to use the same nginx.conf file for reverse proxy for docker-compose and kubernetesnginx docker compose redirect delay

What causes the sudden spool-up sound from an F-16 when enabling afterburner?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

Why was the "bread communication" in the arena of Catching Fire left out in the movie?

Where to refill my bottle in India?

Email Account under attack (really) - anything I can do?

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

Is there a way to make member function NOT callable from constructor?

What does 'script /dev/null' do?

Does it makes sense to buy a new cycle to learn riding?

"My colleague's body is amazing"

Can I find out the caloric content of bread by dehydrating it?

How can I add custom success page

New order #4: World

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

Why is the design of haulage companies so “special”?

Prime joint compound before latex paint?

What does it exactly mean if a random variable follows a distribution

Copycat chess is back

What happens when a metallic dragon and a chromatic dragon mate?

Check if two datetimes are between two others

Need help identifying/translating a plaque in Tangier, Morocco

Typesetting a double Over Dot on top of a symbol

Crop image to path created in TikZ?



NGINX reverse proxy not working to other docker container


Difference between proxy server and reverse proxy serverwhat's wrong with this configuration for nginx as reverse proxy for node.js?From inside of a Docker container, how do I connect to the localhost of the machine?Nginx and php-fpm docker composePeriodic drop in throughput of nginx reverse proxy, what can it be?Nginx as reverse proxy for docker containersDocker and NGINX - host not found in upstream when building with docker-composeDocker issue with nginx reverse proxying to golang serverHow to use the same nginx.conf file for reverse proxy for docker-compose and kubernetesnginx docker compose redirect delay






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a setup with two docker containers in a docker compose. Now I want to use proxy_pass feature from nginx to proxy the connection from nginx to other container.



docker compose



version: '3.4'
services:
reverse_proxy:
image: nginx:alpine
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./error.log:/var/log/nginx/error.log
ports:
- "8081:8081"
apigateway.api:
image: $REGISTRY:-configurator/apigateway.api:$TAG:-latest
build:
context: .
dockerfile: src/Services/ApiGateway/ApiGateway.Api/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
ports:
- "58732:80"


nginx conf



worker_processes 1;

events
multi_accept on;
worker_connections 65535;


http
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M;

# MIME
include mime.types;
default_type application/octet-stream;

upstream apigateway
server apigateway.api:58732;


server
listen 8081;
# reverse proxy
location /configurator-api-gw/
proxy_pass http://apigateway/;
proxy_redirect off;
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-Host $server_name;






When I now access http://localhost:8081/configurator-api-gw/swagger I'm getting following error in the error.log. I have tried also different approaches and some other examples but I don't get it why this is not working.




2019/03/08 06:30:29 [error] 7#7: *6 connect() failed (111: Connection
refused) while connecting to upstream, client: 172.28.0.1, server: ,
request: "GET /configurator-api-gw/swagger HTTP/1.1", upstream:
"http://172.28.0.5:58732/swagger", host: "localhost:8081"











share|improve this question




























    0















    I have a setup with two docker containers in a docker compose. Now I want to use proxy_pass feature from nginx to proxy the connection from nginx to other container.



    docker compose



    version: '3.4'
    services:
    reverse_proxy:
    image: nginx:alpine
    volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf
    - ./error.log:/var/log/nginx/error.log
    ports:
    - "8081:8081"
    apigateway.api:
    image: $REGISTRY:-configurator/apigateway.api:$TAG:-latest
    build:
    context: .
    dockerfile: src/Services/ApiGateway/ApiGateway.Api/Dockerfile
    environment:
    - ASPNETCORE_ENVIRONMENT=Development
    - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
    - "58732:80"


    nginx conf



    worker_processes 1;

    events
    multi_accept on;
    worker_connections 65535;


    http
    charset utf-8;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    server_tokens off;
    log_not_found off;
    types_hash_max_size 2048;
    client_max_body_size 16M;

    # MIME
    include mime.types;
    default_type application/octet-stream;

    upstream apigateway
    server apigateway.api:58732;


    server
    listen 8081;
    # reverse proxy
    location /configurator-api-gw/
    proxy_pass http://apigateway/;
    proxy_redirect off;
    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-Host $server_name;






    When I now access http://localhost:8081/configurator-api-gw/swagger I'm getting following error in the error.log. I have tried also different approaches and some other examples but I don't get it why this is not working.




    2019/03/08 06:30:29 [error] 7#7: *6 connect() failed (111: Connection
    refused) while connecting to upstream, client: 172.28.0.1, server: ,
    request: "GET /configurator-api-gw/swagger HTTP/1.1", upstream:
    "http://172.28.0.5:58732/swagger", host: "localhost:8081"











    share|improve this question
























      0












      0








      0








      I have a setup with two docker containers in a docker compose. Now I want to use proxy_pass feature from nginx to proxy the connection from nginx to other container.



      docker compose



      version: '3.4'
      services:
      reverse_proxy:
      image: nginx:alpine
      volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./error.log:/var/log/nginx/error.log
      ports:
      - "8081:8081"
      apigateway.api:
      image: $REGISTRY:-configurator/apigateway.api:$TAG:-latest
      build:
      context: .
      dockerfile: src/Services/ApiGateway/ApiGateway.Api/Dockerfile
      environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      ports:
      - "58732:80"


      nginx conf



      worker_processes 1;

      events
      multi_accept on;
      worker_connections 65535;


      http
      charset utf-8;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      server_tokens off;
      log_not_found off;
      types_hash_max_size 2048;
      client_max_body_size 16M;

      # MIME
      include mime.types;
      default_type application/octet-stream;

      upstream apigateway
      server apigateway.api:58732;


      server
      listen 8081;
      # reverse proxy
      location /configurator-api-gw/
      proxy_pass http://apigateway/;
      proxy_redirect off;
      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-Host $server_name;






      When I now access http://localhost:8081/configurator-api-gw/swagger I'm getting following error in the error.log. I have tried also different approaches and some other examples but I don't get it why this is not working.




      2019/03/08 06:30:29 [error] 7#7: *6 connect() failed (111: Connection
      refused) while connecting to upstream, client: 172.28.0.1, server: ,
      request: "GET /configurator-api-gw/swagger HTTP/1.1", upstream:
      "http://172.28.0.5:58732/swagger", host: "localhost:8081"











      share|improve this question














      I have a setup with two docker containers in a docker compose. Now I want to use proxy_pass feature from nginx to proxy the connection from nginx to other container.



      docker compose



      version: '3.4'
      services:
      reverse_proxy:
      image: nginx:alpine
      volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./error.log:/var/log/nginx/error.log
      ports:
      - "8081:8081"
      apigateway.api:
      image: $REGISTRY:-configurator/apigateway.api:$TAG:-latest
      build:
      context: .
      dockerfile: src/Services/ApiGateway/ApiGateway.Api/Dockerfile
      environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      ports:
      - "58732:80"


      nginx conf



      worker_processes 1;

      events
      multi_accept on;
      worker_connections 65535;


      http
      charset utf-8;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      server_tokens off;
      log_not_found off;
      types_hash_max_size 2048;
      client_max_body_size 16M;

      # MIME
      include mime.types;
      default_type application/octet-stream;

      upstream apigateway
      server apigateway.api:58732;


      server
      listen 8081;
      # reverse proxy
      location /configurator-api-gw/
      proxy_pass http://apigateway/;
      proxy_redirect off;
      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-Host $server_name;






      When I now access http://localhost:8081/configurator-api-gw/swagger I'm getting following error in the error.log. I have tried also different approaches and some other examples but I don't get it why this is not working.




      2019/03/08 06:30:29 [error] 7#7: *6 connect() failed (111: Connection
      refused) while connecting to upstream, client: 172.28.0.1, server: ,
      request: "GET /configurator-api-gw/swagger HTTP/1.1", upstream:
      "http://172.28.0.5:58732/swagger", host: "localhost:8081"








      docker-compose reverse-proxy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 7:14









      elvir.dolicelvir.dolic

      5419




      5419






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I have solved the problem. The problem is with server apigateway.api:58732; Here it needs to be used Port 80 as this inside of the docker network.






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058427%2fnginx-reverse-proxy-not-working-to-other-docker-container%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I have solved the problem. The problem is with server apigateway.api:58732; Here it needs to be used Port 80 as this inside of the docker network.






            share|improve this answer



























              0














              I have solved the problem. The problem is with server apigateway.api:58732; Here it needs to be used Port 80 as this inside of the docker network.






              share|improve this answer

























                0












                0








                0







                I have solved the problem. The problem is with server apigateway.api:58732; Here it needs to be used Port 80 as this inside of the docker network.






                share|improve this answer













                I have solved the problem. The problem is with server apigateway.api:58732; Here it needs to be used Port 80 as this inside of the docker network.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 11 at 12:49









                elvir.dolicelvir.dolic

                5419




                5419





























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058427%2fnginx-reverse-proxy-not-working-to-other-docker-container%23new-answer', 'question_page');

                    );

                    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







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved