0
  • I have 1st domain name site1.com - self-hosted wordpress and contains posts and pages. (everything good, no issue at all)
  • I have 2nd domain name site2.com - nothing hosted (dns pointing to same server as site1.com domain)

I need to configure the nginx server in such a way that, when users access site2.com, they should get the content of site1.com/site2 wordpress page. (Then the others pages links inside that page are fine as site2.com is considered part of site1.com and users can click the load content with site1.com links)

Details

  • I have tried proxy_pass etc but didn't worked any.
  • site2.com -> site1.com/site2 redirection is working with several techniques but I dont need that as I need site2.com landed with same url on top but site1.com/site2 content.
  • nginx version: nginx/1.14.2
  • OS - Debian GNU/Linux 10 (buster)
  • If there are other ways (non-nginx), still acceptable.

Thanks in advance.

0

Update: This is working with below configuration after adding proxy_ssl_server_name on;

Sample configuration below:

server {    
    index index.php index.html index.htm;

    server_name site2.com www.site2.com;

    access_log /var/log/nginx/access_site2.log;
    error_log /var/log/nginx/error_site2.log;

    location / {
        proxy_pass https://www.site1.com/site2/;
        proxy_ssl_server_name on;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site2.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site2.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = www.site2.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = site2.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;
    server_name site2.com www.site2.com;
    return 404; # managed by Certbot
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.