Answer the question
In order to leave comments, you need to log in
How to setup Redirect on Nginx proxy?
Good day.
There are a number of users whose http / https requests TO ANY SITE in a certain situation (depending on the defined Radius attribute) should go to an internal site (that is, when a user tries to open google.com, the request should be proxied to https://10.1.1.100 :8088),because users and the site are in different broadcast domains, Nginx Proxy is raised between them with two network interfaces. Accordingly, the users themselves do not know anything about 10.1.1.100, but their DNS server correctly resolves example.com to an external IP address on Nginx Proxy. User traffic is blocked by the firewall family inet filter on the Juniper router - but at the same time, http / https requests of these users are wrapped in a virtual machine with Nginx, and are visible using tcpdump (that is, user A's request to google.com), but Nginx itself sees only direct accessing it either by domain name or by IP (if you write example.com in the browser). How to make all requests go to Nginx? If this is possible using Nginx, preferably without iptables and changing ports.
map $host $target {
example.com 0;
default 1;
}
server {
listen 80;
listen 443 ssl http2 default_server;
server_name _;
if ($target){
return 301 $scheme://example.com;
}
location / {
proxy_pass https://10.1.1.100:8088;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question