<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><tt>Hallo,</tt></p>
<p>I added <code>include </code>for the location config files may
it makes it better readable but still no clue hoiw to reach UNIX
socket proxied webserver in LAN.<br>
</p>
<pre><code>
</code></pre>
<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;
include app1location.conf
}
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
#include letsencrypt.conf;
server_app2 app2subdomain.domain.eu;
include app1location.conf
}
</code></pre>
<p><strong>app1location.conf</strong> (location file for proxied web
server)</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><strong>app2location.conf</strong> (location file for proxied web
server)</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>
<p>On 21.09.2018 08:34, Stefan Müller wrote:<br>
</p>
<blockquote type="cite"
cite="mid:1abfde26-8aef-5e22-5c35-671d81826b6a@gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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"
moz-do-not-send="true">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"
moz-do-not-send="true">post</a> </li>
<li><a
href="https://serverfault.com/questions/538803/nginx-reverse-ssl-proxy-with-multiple-subdomains"
moz-do-not-send="true">nginx reverse ssl proxy with
multiple subdomains</a></li>
<li><a
href="https://serverfault.com/questions/677868/using-nginx-as-webserver-and-reverse-proxy"
moz-do-not-send="true">Using Nginx as Webserver</a> </li>
<li><a
href="https://serverfault.com/questions/433053/nginx-to-apache-reverse-proxy-instruct-use-of-unix-sockets"
moz-do-not-send="true">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" moz-do-not-send="true">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"
moz-do-not-send="true">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"
moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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>
</blockquote>
</body>
</html>