Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

344
Views
infinite loop when setting up reverse proxy with docker and nginx

I'm setting up the reverse proxy with Docker and Nginx.

I used the page https://example.org/ for an example.

  1. I set up the custom domain with local mapping in /etc/hosts 127.0.0.1 example.org

  2. I set up the docker-compose file as below

version: '3'
services:
  nginx:
    image: nginx:latest
    container_name: nginx-reverse-proxy
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./nginx-selfsigned.crt:/etc/nginx/nginx-selfsigned.crt
      - ./nginx-selfsigned.key:/etc/nginx/nginx-selfsigned.key
    ports:
      - 80:80
      - 443:443
  1. Then I set up the nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    server {
       listen 80 default_server;
       listen 443 ssl;
       ssl_certificate nginx-selfsigned.crt;
       ssl_certificate_key nginx-selfsigned.key;
       server_name example.org;
       add_header Last-Modified $date_gmt;
       proxy_cache_bypass 1;

       location / {
           add_header  X-Upstream  'default docker' always;
           proxy_pass https://example.org;
           proxy_ssl_server_name on;
       }
    }

    include servers/*;
}

But after I run docker compose up

Then I access the page https://example.org

I got 502 bad gateway error with a lot of headers X-Upstream: default docker added which I configured

I don't know which one is wrong in the configuration :( enter image description here

UPDATED:

I'm not finding out the issue yet.

I decided to go with proxy_pass https://ip_address rather than with the domain name. I don't understand why it work with nginx on local machine but not with nginx in docker

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!