skip to Main Content

I’m running an nginx reverse proxy to be able to run multiple servers behind my firewall. I noticed on my mail server the error log is filled with "failed login from < local ip of nginx >" and I was wondering how can I set it so I get the remote IP of the person/bot that is trying to login so I might use that information for auto blocking those addresses (for example)?

This is my current config:

server {
    listen 8443 ssl http2;
    server_name mail.domain.com;

    location / {
        proxy_set_header Host $host;
        proxy_pass https://<internal ip>/;
        client_max_body_size 0;
        proxy_connect_timeout 3600;
        proxy_send_timeout 3600;
        proxy_read_timeout 3600;
        send_timeout 3600;
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    Just found out my mail server (Kerio) does nothing with the information forwarded by the reverse proxy, so the only thing I can do is hope for an update that does.


  2. I think you’re looking for one of these

    proxy_set_header   X-Real-IP          $remote_addr;
    proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
    

    you can add these to http, server or location block and read the header in your app to filter the request

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search