I have haproxy in front of nginx, which simply serves static content.

Direct access via nginx works perfectly fine - e.g., https://my-nginx-domain.com/some-sub-dir/image.jpg. Here's the nginx configuration:

server {
    listen 443 ssl;
    ssl_certificate /etc/nginx/certificate.pem;
    ssl_certificate_key /etc/nginx/certificate_key.pem;
    location / {
        try_files $uri $uri/ @root;
    location @root {
        root /usr/share/nginx/html; # image.jpg is here

Trying to access the images from haproxy (e.g., https://my-haproxy-domain.com:9999/some-sub-dir/image.jpg) returns a http/404. Here's the haproxy configuration:

frontend IMAGES_FE
    bind *:9999 ssl crt certificate.pem
    use_backend IMAGES_BE if { hdr(Host) -i my-haproxy-domain.com:9999 }

backend IMAGES_BE
    mode http
    server my-nginx-server  # my-nginx-domain.com ip address

What am I missing?


  • From what you've provided, it looks like your nginx server traffic is on port 443, not port 9999 (haproxy will use the same port as the client connected to if unset), and uses ssl. Can you try changing the nginx server line to: server my-nginx-server ssl verify none? Note that it may be better if you don't turn off ssl verifcation (verify none), I just added it to help debug the issue. – mweiss May 27 at 6:15
  • Ah, I made a few typos in my comment: * nginx server line -> haproxy server line * verifcation -> verification – mweiss May 27 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.