cannot get real ip on apache backend behind nginx reverse proxy












0















I'm unable to get the real ip of the client when accessing my apache web server which is behind an nginx reverse proxy. These are two virtual box machines. I'm using ubuntu 18.04 on both of them.
nginx reverse proxy: 192.168.80.53 and apache backend: 192.168.80.54



nginx configuration is this:



server {
listen 443;
server_name test3.de;
ssl on;
ssl_certificate /etc/ssl/crt/vinci-u18iptables.crt;
ssl_certificate_key /etc/ssl/crt/vinci-u18iptables.key;

location / {
proxy_pass http://test2.de;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
send_timeout 60;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}


(test3.de is already associated with the apache backend in /etc/hosts on the nginx reverse proxy)
I've got the following configuration on apache.conf:



RemoteIPHeader X-Forwarded-For
LogFormat "%v:%p %a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" vhost_combined
LogFormat "%a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%a %l %u %t "%r" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


remoteip_module is enabled.
I only have one single vhost enabled:



<VirtualHost *:80>
ServerName test2.de
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


So, when accessing https://test3.de on my browser (on 192.168.80.109), I get the following in my apache backend:



192.168.80.53 - - [23/Jan/2019:14:47:38 +0000] "GET /info.php HTTP/1.1" 200 21788 referer: "-" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98
Chrome/71.0.3578.98 Safari/537.36"


So, still the ip of the reverse proxy instead of 192.168.80.109.
Any ideas what I'm missing here? This is simple basic configuration.










share|improve this question



























    0















    I'm unable to get the real ip of the client when accessing my apache web server which is behind an nginx reverse proxy. These are two virtual box machines. I'm using ubuntu 18.04 on both of them.
    nginx reverse proxy: 192.168.80.53 and apache backend: 192.168.80.54



    nginx configuration is this:



    server {
    listen 443;
    server_name test3.de;
    ssl on;
    ssl_certificate /etc/ssl/crt/vinci-u18iptables.crt;
    ssl_certificate_key /etc/ssl/crt/vinci-u18iptables.key;

    location / {
    proxy_pass http://test2.de;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    send_timeout 60;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    }
    }


    (test3.de is already associated with the apache backend in /etc/hosts on the nginx reverse proxy)
    I've got the following configuration on apache.conf:



    RemoteIPHeader X-Forwarded-For
    LogFormat "%v:%p %a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" vhost_combined
    LogFormat "%a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" combined
    LogFormat "%a %l %u %t "%r" %>s %O" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent


    remoteip_module is enabled.
    I only have one single vhost enabled:



    <VirtualHost *:80>
    ServerName test2.de
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>


    So, when accessing https://test3.de on my browser (on 192.168.80.109), I get the following in my apache backend:



    192.168.80.53 - - [23/Jan/2019:14:47:38 +0000] "GET /info.php HTTP/1.1" 200 21788 referer: "-" "Mozilla/5.0 (X11; Linux x86_64)
    AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98
    Chrome/71.0.3578.98 Safari/537.36"


    So, still the ip of the reverse proxy instead of 192.168.80.109.
    Any ideas what I'm missing here? This is simple basic configuration.










    share|improve this question

























      0












      0








      0








      I'm unable to get the real ip of the client when accessing my apache web server which is behind an nginx reverse proxy. These are two virtual box machines. I'm using ubuntu 18.04 on both of them.
      nginx reverse proxy: 192.168.80.53 and apache backend: 192.168.80.54



      nginx configuration is this:



      server {
      listen 443;
      server_name test3.de;
      ssl on;
      ssl_certificate /etc/ssl/crt/vinci-u18iptables.crt;
      ssl_certificate_key /etc/ssl/crt/vinci-u18iptables.key;

      location / {
      proxy_pass http://test2.de;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_connect_timeout 60;
      proxy_read_timeout 60;
      proxy_send_timeout 60;
      send_timeout 60;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      }
      }


      (test3.de is already associated with the apache backend in /etc/hosts on the nginx reverse proxy)
      I've got the following configuration on apache.conf:



      RemoteIPHeader X-Forwarded-For
      LogFormat "%v:%p %a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" vhost_combined
      LogFormat "%a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" combined
      LogFormat "%a %l %u %t "%r" %>s %O" common
      LogFormat "%{Referer}i -> %U" referer
      LogFormat "%{User-agent}i" agent


      remoteip_module is enabled.
      I only have one single vhost enabled:



      <VirtualHost *:80>
      ServerName test2.de
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>


      So, when accessing https://test3.de on my browser (on 192.168.80.109), I get the following in my apache backend:



      192.168.80.53 - - [23/Jan/2019:14:47:38 +0000] "GET /info.php HTTP/1.1" 200 21788 referer: "-" "Mozilla/5.0 (X11; Linux x86_64)
      AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98
      Chrome/71.0.3578.98 Safari/537.36"


      So, still the ip of the reverse proxy instead of 192.168.80.109.
      Any ideas what I'm missing here? This is simple basic configuration.










      share|improve this question














      I'm unable to get the real ip of the client when accessing my apache web server which is behind an nginx reverse proxy. These are two virtual box machines. I'm using ubuntu 18.04 on both of them.
      nginx reverse proxy: 192.168.80.53 and apache backend: 192.168.80.54



      nginx configuration is this:



      server {
      listen 443;
      server_name test3.de;
      ssl on;
      ssl_certificate /etc/ssl/crt/vinci-u18iptables.crt;
      ssl_certificate_key /etc/ssl/crt/vinci-u18iptables.key;

      location / {
      proxy_pass http://test2.de;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_connect_timeout 60;
      proxy_read_timeout 60;
      proxy_send_timeout 60;
      send_timeout 60;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      }
      }


      (test3.de is already associated with the apache backend in /etc/hosts on the nginx reverse proxy)
      I've got the following configuration on apache.conf:



      RemoteIPHeader X-Forwarded-For
      LogFormat "%v:%p %a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" vhost_combined
      LogFormat "%a %l %u %t "%r" %>s %O referer: "%{Referer}i" "%{User-Agent}i"" combined
      LogFormat "%a %l %u %t "%r" %>s %O" common
      LogFormat "%{Referer}i -> %U" referer
      LogFormat "%{User-agent}i" agent


      remoteip_module is enabled.
      I only have one single vhost enabled:



      <VirtualHost *:80>
      ServerName test2.de
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>


      So, when accessing https://test3.de on my browser (on 192.168.80.109), I get the following in my apache backend:



      192.168.80.53 - - [23/Jan/2019:14:47:38 +0000] "GET /info.php HTTP/1.1" 200 21788 referer: "-" "Mozilla/5.0 (X11; Linux x86_64)
      AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98
      Chrome/71.0.3578.98 Safari/537.36"


      So, still the ip of the reverse proxy instead of 192.168.80.109.
      Any ideas what I'm missing here? This is simple basic configuration.







      ubuntu apache-http-server nginx reverse-proxy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 23 at 14:50









      LethargosLethargos

      11




      11






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397502%2fcannot-get-real-ip-on-apache-backend-behind-nginx-reverse-proxy%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397502%2fcannot-get-real-ip-on-apache-backend-behind-nginx-reverse-proxy%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

          Eduardo VII do Reino Unido