-1

I need to test a website before changing DNS records.

There are tools such as Skipdns.link and in the past hostcx. I need this but without the limitation of skipdns.link.

For example all URLs of skipdns.example.com should showing the content of example.com. For this I made a start:

server {
    listen 80;
    server_name skipdns.example.com;
    return 301 https://$host$request_uri;
}

server { listen 443 ssl; server_name skipdns.example.com;

ssl_certificate /etc/letsencrypt/live/skipdns.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/skipdns.example.com/privkey.pem;

location / {
    proxy_pass https://example.com;
    proxy_set_header Host example.com;
    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;

    # Substitutie van example.com naar skipdns.example.com
    sub_filter 'example.com' 'skipdns.example.com';
    sub_filter_once off;

    # Optioneel: Substitutie van HTTPS naar HTTP, als nodig
    sub_filter 'https://skipdns.example.com' 'http://skipdns.example.com';

    # URL's in HTTP headers en response bodies aanpassen
    sub_filter_types *;
}

}

The website example.com is shown but the URLs are not all rewritten. If I click on the logo of the menu it still shows example.com.

What am I missing?

Greg Askew
  • 39,132
Noob
  • 97
  • 1
  • 6

1 Answers1

0

Rewriting like that at the web server seems to me like not enough testing as in production. Different TLS certificate, not testing that exactly. The wrong links you found.

Consider keeping the example.com service name the same, but forward specific clients to the test backend.

Keep DNS pointing at the load balancer. Let me take the liberty of making up names, say it is currently live with backend hosts web4.example.com and web5.example.com.

Tweak the load balancer such that the specific user agents get the test backend web6 but are not rewritten otherwise. With nginx this can use map on an override variable. And if using reverse proxy, would be using this variable for proxy_pass. Could be based on a cookie or IP address ranges via http_geo.

Everything about the request remains example.com, it just is served by a special http server for this user agent.

If instead you wished for an independent web site with more differences, a different name makes a lot of sense. test.example.com or some different domain. Separate copy of web site content. Testing of web server operations without affecting production, like load balancing and TLS certificates.

John Mahowald
  • 36,071