How to reverse proxy if user use dekstop go to proxy_pass domain.xyz;
and if use mobile go to proxy_pass mobile.domain.xyz;
? me use nginx as reverse web server. this my sample code :
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/nginx/ssl/cert.crt;
ssl_certificate_key /etc/nginx/ssl/cert.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
# modern configuration
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
add_header Strict-Transport-Security "max-age=63072000" always;
# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;
# verify chain of trust of OCSP response using Root CA and Intermediate certs
ssl_trusted_certificate /etc/nginx/ssl/cert-ca.crt;
# replace with the IP address of your resolver
resolver 1.1.1.1 1.0.0.1;
location ~ /.well-known {
root /var/www/html;
}
#Custom Sitemap
#location ~ ^/(sitemap.xml) {
# root /var/www/html;
#}
#Google verification
#location ~ ^/(googlee1a07b36e5db19e8.html) {
# root /var/www/html;
#}
location / {
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;
#sub_filter "'http:'" "'https:'";
sub_filter 'www.domain.xyz' '$host';
sub_filter 'domain.xyz' '$host';
proxy_redirect https://www.domain.xyz https://$host;
proxy_redirect http://www.domain.xyz https://$host;
proxy_ssl_server_name on;
proxy_pass http://www.domain.xyz;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}
can me make a dynamic reverse proxy using nginx? thanks for help