Score:1

How to dynamic reverse proxy nginx desktop and mobile?

ax flag
Xen

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

djdomi avatar
za flag
Please be more Detailed, you want to redirect mobile users to a other sub domain as other users?
Michael Hampton avatar
cz flag
How can you tell which is a mobile user?
djdomi avatar
za flag
@MichaelHampton i belive he will decide on the CLient's browser Agent
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.