3

I have following nginx conf

upstream domain1 {
  server 127.0.0.1:3000;
  server 127.0.0.1:3001;
}




server {
  listen   80;
  server_name demo.domain.com;

  root   /var/apps/myapp/public;

  location / {
                proxy_set_header  X-Real-IP  $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;

                if (-f $request_filename/index.html) {
                                 rewrite (.*) $1/index.html break;
                }

                if (-f $request_filename.html) {
                                 rewrite (.*) $1.html break;
                }

                if (!-f $request_filename) {
                                 proxy_pass http://domain1;
                                 break;
                }
  }

 location /mail_us1 {
                proxy_pass       http://127.0.0.1:1080;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
 }


}

I'm trying to set up mailcatcher on my server (mailcatcher running at 1080 port)

With my limited experience in nginx, I was assuming that the following directive would work good

 location /mail_us1 {
                    proxy_pass       http://127.0.0.1:1080;
                    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Host $http_host;
     }

But unfortunately I'm not able to get the desired output and I keeping getting landed on nginx pages that states

No Dice

The message you were looking for does not exist, or doesn't have content of this type.

Can Any one tell me what wrong I'm doing

Note:

- curl http://localhost:1080 (work )

- iptables -L (is empty)
Ratatouille
  • 1,372
  • 5
  • 23
  • 50

1 Answers1

3

This works for me:

location /mailcatcher {
  rewrite /mailcatcher/(.*) /$1 break;
  proxy_pass http://mailcatcher/;
}

location ~ ^/assets {
  proxy_pass http://mailcatcher;
}

location ~ ^/messages {
  proxy_pass http://mailcatcher;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}
Holger Amann
  • 31
  • 1
  • 2