<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
To add a bit more information.<br>
<br>
Server1 is hosted, has both IPv4 and 6.<br>
Server2 is on the end of an adsl line within a RFC1918 network where
the external port 80 points to another server which cannot be
changed.<br>
Another complication is that internet access from some client
locations is heavily restricted, so using an alternative port may
not work.<br>
The LAN has full IPv6 capability and there's some video streaming
done on server2 so direct LAN access is preferred.<br>
<br>
I managed to get it working with the below config on server2.<br>
<br>
server {<br>
listen [::]:80;<br>
server_name
~^(?<subdomain>\w+)\.example\.com$;<br>
set $upstream <a class="moz-txt-link-rfc2396E" href="http://$subdomain">"http://$subdomain"</a>;<br>
location / {<br>
proxy_set_header Host $host;<br>
proxy_pass $upstream;<br>
}<br>
}<br>
upstream netflow {<br>
server 127.0.0.1:8080;<br>
}<br>
upstream ntop {<br>
server 127.0.0.1:3000;<br>
}<br>
upstream wifi {<br>
server 127.0.0.1:8443;<br>
}<br>
<br>
I was initially tripped up by the proxy_pass line, I did not get the
desired effect when using 'proxy_pass <a class="moz-txt-link-freetext" href="http://$subdomain">http://$subdomain</a>;' <br>
<br>
Steve.<br>
<br>
<div class="moz-cite-prefix">On 31/01/15 16:21, Lloyd Chang wrote:<br>
</div>
<blockquote
cite="mid:CAKbR+sw0eky=1wPh-akTrioV3BBsh14F=2jVNH_AwgTGiAOyNw@mail.gmail.com"
type="cite">Hello Steve,
<div><br>
</div>
<div>• Best answer is try and see if it meets your expectations;
thanks</div>
<div><br>
</div>
<div>• While reading your snippet, my initial questions are —
Why 2 servers? Why not simplify?</div>
<div><br>
</div>
<div>• In your proposal: server1, listen to ?? TCP
port(s) on public IPv4, and IPv6 to proxy_pass to server2, then
server2 listen on public IPv6, and IPv4 to proxy_pass to
subdomain, with upstream (perhaps for load
balance and/or failover?) — As you agree, this is
slightly complicated</div>
<div><br>
</div>
<div>• Why not simplify? — Reconfigure DNS for cname-server1 to
server2, for IPv4 and IPv6</div>
<div><br>
</div>
<div>• In your snippet, server2 supports IPv4 and IPv6 if you
expect it to upstream via private IPv4 127.0.0.1:[…]</div>
<div><br>
</div>
<div>• I don't fully understand why server2 upstream isn't IPv6
::1:[…] considering your primary intent for server2 is IPv6
usage</div>
<div><br>
</div>
<div>• Perhaps you meant upstream localhost:[…] to try both IPv4
and IPv6? Thanks</div>
<div><br>
</div>
Cheers,
<div>Lloyd<br>
<div>
<div><br>
On Friday, January 30, 2015, Steve Wilson <<a
moz-do-not-send="true"
href="mailto:lists-nginx@swsystem.co.uk">lists-nginx@swsystem.co.uk</a>>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Slightly complicated setup with 2 nginx servers.<br>
<br>
server1 has a public ipv4 address using proxy_pass to
server2 over ipv6 which only has a public ipv6, this then
has various upstreams for each subdomain.<br>
<br>
ipv6 capable browsers connect directly to server2, those
with only ipv4 will connect via server1.<br>
<br>
I'm currently considering something like the below config.<br>
<br>
<br>
server1 - proxy all subdomain requests to upstream ipv6
server:<br>
<br>
http {<br>
server_name *.<a moz-do-not-send="true"
href="http://example.com" target="_blank">example.com</a>;<br>
location / {<br>
proxy_pass http://fe80::1337;<br>
}<br>
}<br>
<br>
server2:<br>
<br>
http {<br>
server_name ~^(?<subdomain>\w+)\.example\.com$;<br>
location / {<br>
proxy_pass <a class="moz-txt-link-freetext" href="http://$subdomain">http://$subdomain</a><br>
}<br>
<br>
upstream subdomain1 {<br>
server <a moz-do-not-send="true"
href="http://127.0.0.1:1234" target="_blank">127.0.0.1:1234</a>;<br>
}<br>
}<br>
<br>
The theory here is that each subdomain and upstream would
match, meaning that when adding another upstream it would
just need the upstream{} block configuring and
automatically work.<br>
<br>
I realise there's dns stuff etc but that's out of scope
for this list and I can deal with that.<br>
<br>
Does this seem sound? It's not going to see major usage
but hopefully this will reduce work when adding new
upstreams.<br>
<br>
If you've a better way to achieve this please let me know.<br>
<br>
Steve.<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a moz-do-not-send="true">nginx@nginx.org</a><br>
<a moz-do-not-send="true"
href="http://mailman.nginx.org/mailman/listinfo/nginx"
target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>