chrismccord / mailgun

Elixir Mailgun Client
MIT License
194 stars 95 forks source link

401 response when defining local ip in endpoint config #36

Open nathanhornby opened 8 years ago

nathanhornby commented 8 years ago

I’m having trouble getting mailgun to play nice in production. When defining the local IP in the config as follows:

http: [ip: {127, 0, 0, 1}, port: {:system, "PORT"}],
url: [host: "redacteddomain.com", port: 443],

This causes mailgun to return a 401 error. Simply removing ip: {127, 0, 0, 1} resolves the issue.

I’ve got that in place to prevent direct outside access to the ip:port (as otherwise you can can access the app directly on an http connection which is what the phoenix app is using, SSL is handled by nginx).

Is this expected behaviour or issue-worthy?

nathanhornby commented 8 years ago

Ah, I'd misidentified the issue it seems. Re-introducing the ip, but removing the port from the url seemed to resolve the issue. Is this something to do with how the package builds the request? I'm curious if I've done something wrong in my config or if the package just doesn't like it.

xjlu commented 8 years ago

I had exactly the same issue on production. It worked in development mode, but got 401 on heroku.

Solution: I simply switched to use Bamboo. It has a mailgun adapter since 0.5 (almost ready to use httpoison to write the api call directly). The only difference in the config is the domain part: only use the your.domain part.