I am using Nginx to reverse proxy a handful of web servers with each being streamed which works really well, this is the config:
stream {
map $ssl_preread_server_name $name {
portal1.site.com portal1_backend;
portal2.site.com portal1_backend;
portal3.site.com portal1_backend;
portal4.site.com portal1_backend;
}
upstream portal1_backend {
server 10.1.1.1:443;
}
upstream portal2_backend {
server 10.1.1.2:443;
}
upstream portal3_backend {
server 10.1.1.3:443;
}
upstream portal4_backend {
server 10.1.1.4:443;
}
server {
listen 10.1.2.2:443;
proxy_pass $name;
ssl_preread on;
}
http {
server {
listen 80;
server_name portal1.site.com;
location / {
return 301 https://$server_name$request_uri;
}
location /.well-known/ {
proxy_pass http://10.1.1.1:80;
} # do not redirect requests for iframe location
}
server {
listen 80;
server_name portal2.site.com;
location / {
return 301 https://$server_name$request_uri;
}
location /.well-known/ {
proxy_pass http://10.1.1.2:80;
}
}
server {
listen 80;
server_name portal3.site.com;
location / {
return 301 https://$server_name$request_uri;
}
location /.well-known/ {
proxy_pass http://10.1.1.3:80;
}
}
server {
listen 80;
server_name portal4.site.com;
location / {
allow 1.2.3.4;
deny all;
return 301 https://$server_name$request_uri;
}
location /.well-known/ {
proxy_pass http://10.1.1.4:80;
}
}
}
Each has port 80 redirecting to https, except for the .well-know location for Lets Encrypt.
What I need to be able to do is limit what IP addresses are able to connect to the 4th server without impacting current functionality, and not restricting the other servers.
This config was put together referring to Nginx TCP forwarding based on hostname
Is this possible?