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.