<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hallo,</p>
    <p>I am trying to configure nginx as a reverse proxy for multiple
      servers on my LAN. They should go out on my WAN with different
      subdomains.</p>
    <div class="postcell post-layout--right">
      <div class="post-text" itemprop="text">
        <p>
          Unlike the approach described in <a
href="https://serverfault.com/questions/706694/use-nginx-as-reverse-proxy-for-multiple-servers">Use
            Nginx as Reverse Proxy for multiple servers</a> I want to
          use UNIX socket for the interprocess communication on my
          server. </p>
        <p>Based on </p>
        <ol>
          <li>the above <a
href="https://serverfault.com/questions/706694/use-nginx-as-reverse-proxy-for-multiple-servers">post</a>
          </li>
          <li><a
href="https://serverfault.com/questions/538803/nginx-reverse-ssl-proxy-with-multiple-subdomains">nginx
              reverse ssl proxy with multiple subdomains</a></li>
          <li><a
href="https://serverfault.com/questions/677868/using-nginx-as-webserver-and-reverse-proxy">Using
              Nginx as Webserver</a> </li>
          <li><a
href="https://serverfault.com/questions/433053/nginx-to-apache-reverse-proxy-instruct-use-of-unix-sockets">Nginx
              to apache reverse proxy, instruct use of unix sockets</a></li>
          <li><a
href="https://meta.discourse.org/t/difference-between-socket-and-port-based-connection-to-outer-nginx/60071"
              rel="nofollow noreferrer">Difference between socket- and
              port-based connection to outer NGINX?</a></li>
          <li>keeping in mind the solution given in <a
href="https://serverfault.com/questions/316157/how-do-i-configure-nginx-proxy-pass-node-js-http-server-via-unix-socket">How
              do I configure Nginx proxy_pass Node.js HTTP server via
              UNIX socket?</a> </li>
        </ol>
        <p>my configuration shall look something like this below,
          doesn't it?
          In order to keep the main file slim, I would like to outsource
          the <code>location</code> blocks.<br>
          I find all on the web more or less but nothing about wow I can
          reach the servers in within the LAN? Do I need to set up a
          local DNS server as described in <a
href="https://superuser.com/questions/45789/running-dns-locally-for-home-network">Running
            DNS locally for home network</a>?</p>
        <p><strong>main proxy file</strong> </p>
        <pre><code>server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
    listen [::]:443 ssl;
    #include letsencrypt.conf;
    server_app1 app1subdomain.domain.eu;
    *read app1location.file*
       }

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
    listen [::]:443 ssl;
    #include letsencrypt.conf;
    server_app2 app2subdomain.domain.eu;
    *read app2location.file*
       }
</code></pre>
        <p><strong>location files for proxied web servers:</strong> </p>
        <pre><code>location / {            
    proxy_pass <a class="moz-txt-link-freetext" href="http://unix:/home/app1/app1.com.unix_socket">http://unix:/home/app1/app1.com.unix_socket</a>;
    proxy_set_header X-Real-IP $remote_addr; #Authorization
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;
    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
           }
</code></pre>
        <p>-</p>
        <pre><code>   location / {            
        proxy_pass <a class="moz-txt-link-freetext" href="http://unix:/home/app2/app2.com.unix_socket">http://unix:/home/app2/app2.com.unix_socket</a>;
        proxy_set_header X-Real-IP $remote_addr; #Authorization
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 36000s;
        proxy_redirect off;
               }
</code></pre>
      </div>
    </div>
  </body>
</html>