1

For a new domain x.co I am setting up, I want the root (x.co) to show an external landing page without changing the url to that of the external landing page.

This landing page has been created on hubspot and published at a.hubspot.b/c

Is there a simple way of achieving this? I checked a few answers like 1, 2, 3, but did not get it.

What I have now is below. It forwards to the landing page changing the url to a.hubspot.b/c. I need the url to stay the same x.co.

FWIW, I also use cloudflare caching and DNS.

server {
        listen 80;
        server_name  x.co www.x.co;
        return         301 https://$server_name$request_uri;
}

server {
        listen       443 ssl http2;
        server_name  x.co www.x.co;

        ssl_certificate      x.co.pem;
        ssl_certificate_key  x.co.key;

        ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            #proxy_pass https://x-12345.hubspotpagebuilder.eu/coming-soon/;

            resolver 8.8.8.8;

            proxy_pass https://x-12345.hubspotpagebuilder.eu/coming-soon;
            proxy_set_header Host $host;
            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;


            #root /var/www/frontend/x;
            #root   html;
            #index  index.html index.htm;
        }
    }

Edit/add - stupidly enough I had not bothered checking the nginx error logs. When I did, there were good clues to the problem. The error logs had

"SSL_do_handshake() failed (SSL: error:14094410:SSL routines:ssl3_read_bytes_sslv3 alert handshake failure:SSL alert number 40) while SSL handshaking to upstream, client: 2401: ......" 

(the ...... at the end means there's more text that I didn't type out here. I am using a Cloudflare cert on my backend and redirecting to a hubspot page in nginx - that seemed like a problem.

And it was. The solution was to add proxy_ssl_server_name on;. All the proxy_set_header directives which I copied in desperation was pointless and could happily be gotten ride of. This page proved very useful in explaining the problem and solution.

11
  • I didn't get a couple of things. What should happen with any other request (I mean other that the root request)? Why are you using all those proxy_set_header directives? Are you using them on some purpose or just copy-paste them from some example without understanding what do they really did? Feb 20 at 10:20
  • All proxy_set_headers and the resolver are copy pasted. The rest is my own. When what I had didnt work, I started copy pasting. For non-root requests, a 404 is fine right now.
    – Ahron
    Feb 20 at 10:30
  • Try to remove at least proxy_set_header Host $host; one. You need a resolver only if the domain name for the proxy_pass directive is specified using a variable(s) which is not your case (however it won't do any harm). Feb 20 at 10:35
  • Then I get a Host error bad gateway 502 via Cloudflare
    – Ahron
    Feb 20 at 10:40
  • 1
    Ok, thanks a lot for persisting in trying to help me. I figured it out. It was indeed an SSL issue. Silly of me to not have bothered checking the logs. The solution is to add ` proxy_ssl_server_name on;` all the proxy_set_headers copy pasta is pointless given the nature of the problem. This link proved very useful so maybe you could take a look too - claudiokuenzler.com/blog/1120/…
    – Ahron
    Feb 20 at 13:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.