Welcome! Log In Create A New Profile

Advanced

Second opinion on my config (proxy_pass on multiple vhosts)

Posted by mijdk 
Second opinion on my config (proxy_pass on multiple vhosts)
March 02, 2013 04:41PM
Hi,

After i have fiddled around with my config file, and read the docs / googled etc, i have a configuration that works most of the time, done by mostly trial and error, but would like a second opinion if i understood this correctly, or if there is a better way to do what i'm trying to do.

But lets first describe what i want to achieve:
1) 1 nginx box with 1 public IPv4 and several IPv6 addresses
2) behind this 1 nginx box i have several webservers (both Linux/Win) running on internal ips (IPv4 only)
3) Not all sites will be available on both the public IPv4/IPv6 address, some might be ipv6 only, some ipv4 only, some both (on purpose)

For example (not from current config):
sub1.domain1.ext IPv4: 8.8.8.8
sub2.domain1.ext IPv6: 2001:4860:4860::8888
sub3.domain1.ext IPv4: 8.8.8.8 IPv6: 2001:4860:4860::8888
sub1.domain2.ext IPv6: 2001:4860:4860::4444
sub1.domain3.ext IPv4: 8.8.8.8

But lets say i wanted to add a new vhost for a new ipv4 site below, to a different server with proxy_pass what would i write?, no matter what i seem to try it completely breaks the config, resulting in none of the sites working.

Running:
nginx version: nginx/1.2.3

Here is my current full config:

# Default - both IPv4 / IPv6
server {
listen [::]:80;
server_name 8.8.8.8;
access_log /tmp/default-access.log;
error_log /tmp/default-error.log;

location / {
proxy_pass http://10.20.30.2:80;
proxy_set_header X-Real-IP $remote_addr;
}
}

# only ipv4 - sub1.example.ext
server {
listen 80;
server_name sub1.example.ext;
access_log /tmp/sub1-example-ext-access.log;
error_log /tmp/sub1-example-ext-error.log;

location / {
proxy_pass http://10.20.30.4:80;
proxy_set_header X-Real-IP $remote_addr;
}
}

# only ipv6 - sub2.example.ext
server {
listen [::]:80 ipv6only=on;
server_name sub2.example.ext;
access_log /tmp/sub2.example.ext-access.log;
error_log /tmp/sub2.example.ext-error.log;

location / {
proxy_pass http://10.20.30.5:80;
proxy_set_header X-Real-IP $remote_addr;
}
}

# Just ipv4
server {
listen 80;
server_name test.someotherdomain.ext;
access_log /tmp/test-someotherdomain-ext-access.log;
error_log /tmp/test-someotherdomain-ext-error.log;

location / {
proxy_pass http://10.20.30.3:80;
proxy_set_header X-Real-IP $remote_addr;
}
}

# both ipv4, ipv6
server {
listen 80;
listen [::]:80;
server_name mainsite.ext www.mainsite.ext;
access_log /tmp/mainsite-ext-access.log;
error_log /tmp/mainsite-ext-error.log;

location / {
proxy_pass http://10.20.30.6:80;
proxy_set_header X-Real-IP $remote_addr;
}
}



Edited 1 time(s). Last edit at 03/02/2013 04:43PM by mijdk.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 286
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready