Giter Site home page Giter Site logo

Comments (4)

jaywire avatar jaywire commented on May 21, 2024

Seems I'm having the same issue with LetsEncrypt and Traefik. From what I can tell, the request handler is using "r.RemoteAddr" which is not looking at the actual forwarded headers. It should look for X-Forwarded-For

This makes it kind of difficult to run behind a reverse proxy, unless I'm missing something here. There do seem to be a few methods for accomplishing this with Go.

from docker-ddns.

dstapp avatar dstapp commented on May 21, 2024

I'm running docker-ddns behind Caddy as well, there's nothing special:

asd {
    header / {
      Strict-Transport-Security "max-age=31536000;"
      Referrer-Policy "strict-origin-when-cross-origin"
      X-Content-Type-Options "nosniff"
      X-Frame-Options "DENY"
      X-XSS-Protection "1; mode=block"
      -Server
    }

	proxy / ddns:8080 {
		transparent
	}
}

Since docker-ddns does not use the REMOTE_ADDR request header but you have to pass you address manually (see the &addr= part in your example that is empty in your case), it does not matter what docker-ddns sees as origin IP address. Just send alongside your IP address and it will work.

Hope this helps.

I don't know why in your case it takes the Docker network's IP address when the addr query param is empty but I didn't work with the code base for a longer time and I'm short in time so I cannot check right now.

from docker-ddns.

jaywire avatar jaywire commented on May 21, 2024

Thanks for your reply! I do understand that the IP can be defined in the request manually, it does read the IP if you leave the addr= empty. If I run this without a reverse proxy, it works fine. Similar issue here:

#33

After some research into this, it seems that RemoteAddr only looks at the "last hop", which is going to be whatever the docker net IP of Caddy is.

https://husobee.github.io/golang/ip-address/2015/12/17/remote-ip-go.html

It does appear that "request_handler.go" is using RemoteAddr on line 56:

ip, _, err := net.SplitHostPort(r.RemoteAddr)

75dde3a

I'm using this to manage a number of edge computing devices as part of a larger project, so the ability to remotely detect and update the A record for each FQDN is fantastic. I could request the IP a dozen other ways and simply add it to the curl, but that's no fun. :)

I may sit down this weekend and brush up on some Go. If I something put together to read the "X-Forwarded-For", "X-Real-Ip" headers I'll submit a PR.

from docker-ddns.

sgyurko avatar sgyurko commented on May 21, 2024

This does not need any code change. You can just pass the value in the right place on your reverse proxy.
I'm not familiar with Caddy, but on Apache you'd do:

RewriteRule /update /update?addr=%{CONN_REMOTE_IP} [QSA,P]

The idea is that you can take out the header you are interested in at the proxy level and append it to the query string.

from docker-ddns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.