[Feature Request]: Record the requesting end IP in the log
Hi bro, Thank you very much for your work!
Is there any chance to log the request to the log file? Maybe an environment variable option can be provided.
Hope to get your reply~
Thanks for contacting us. However, if I am remembering correctly, isn’t the IP already in the log?
My logs are all 127.0.0.1:
This is my front-end web server settings, I use caddy:
dns.wx2020.fun {
reverse_proxy /dns-query* localhost:8053
tls [email protected]
try_files {path} {path}/index.php /index.php?{query}
}
Does caddy need to set up more details to achieve its goal?
Oh I see!
The code uses gorilla.CombinedLoggingHandler to print out the log.
This handler doesn’t use X-Forwarded-For to retrieve the client IP address, therefore, the log shows 127.0.0.1.
I believe the developers of Gorilla library don’t intend to change this behavior due to security concerns. Perhaps I need to implement a version of logging myself… But it’s a feature many servers choose to opt-out, I’m hesitating to spend time developing it right now…
ah, just do it when you want to do it.
ah, just do it when you want to do it.
Thank you for understanding! If many people ask for this feature, I will do it. Meanwhile, Pull Requests are welcome!
Okey, i will try it!
Oh I found it!
It’s already in the configuration file, called log_guessed_client_ip.
https://github.com/m13253/dns-over-https/blob/master/doh-server/doh-server.conf#L53
Have you tried it out?
I use it with docker, but when I mount the config file and restart the container after modifying the config file, the configuration file will become the file before the modification. . . Is it a problem with the docker image?
There are my docker-compose file:
doh-server:
container_name: doh-server
image: satishweb/doh-server
hostname: doh-server
user: root
network_mode: host
volumes:
- ./config/doh-server/doh-server.conf:/server/doh-server.conf
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 1m
Try this:
volumes:
- ./config/doh-server/doh-server.conf:/doh-server.conf
I’m not sure if this is the fix, but worth trying it.
I tried to mount it like this, but the file didn't take effect😂...
My docker-compose file:
Looks like you are using a Docker image provided by satishweb/doh-server.
I didn’t author that container image, so you might need to check its Dockerfile to determine the correct way to supply configurations.
Hi @wx2020,
Mounting the custom doh-server.conf at /server/doh-server.conf (reference) should work as expected. I’ve tested it with log_guessed_client_ip set to true, and it’s functioning correctly. Let me know if you’re still encountering any issues—I’d be happy to help troubleshoot further.
Corrected volume mount line:
volumes:
- ./config/doh-server/doh-server.conf:/server/doh-server.conf
Additionally, in the next release of the container image, I’ll be adding environment configuration variables for the following DoH config keys:
log_guessed_client_ip
ecs_allow_non_global_ip
ecs_use_precise_ip
tls_client_auth
tls_client_auth_ca
local_addr
cert
key
It looks like the issue has been fixed on the Dockerfile side. @wx2020 Do you still experience the issue? If not, feel free to close.