How to Create Multiple Domains

Hello Webmasters

This community is really informative and helpful. I installed Discourse on the cloud and now I want to add a couple of subdomains under a user I created. The new subdomains still point to the Discourse forum. I tried to specify the custom directory, but still no luck.

HestiaCP v1.6.2

Any ideas? Thanks in advanced…

Hello @Hussein

please tell the steps you did , I try to regenerate the issue but it’s working fine when I make add website and add domain !

any error logs etc ?

1 Like

Sure, Here are the steps I followed:

First off, I have added this template to nginx.conf to have reverse proxy functioning:

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;

    include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      http://%ip%:%web_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}



server {
    listen      %ip%:%proxy_ssl_port% ssl http2;
    server_name %domain_idn% %alias_idn%;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      https://%ip%:%web_ssl_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}

Then set Backend Template PHP-FPM > Socket. The Discourse is working fin. I added a subdomain and installed WordPress, but it didn’t point to the new website. All it did it redirect me to the Discourse forum.

Here is the error log from nginx

  GNU nano 6.2                                                                    error.log
2022/07/08 13:52:25 [emerg] 354516#354516: invalid port in "%ip%:%proxy_port%" of the "listen" directive in /etc/nginx/nginx.conf:164
2022/07/08 13:52:25 [emerg] 354524#354524: invalid port in "%ip%:%proxy_port%" of the "listen" directive in /etc/nginx/nginx.conf:164
2022/07/08 13:52:25 [emerg] 354529#354529: invalid port in "%ip%:%proxy_port%" of the "listen" directive in /etc/nginx/nginx.conf:164
``

I figure it out, after lengthy attempts with forwards and backwards, the error was misconfiguration the Discourse. Sorry, I am still learning new stuff so it was confusing to me at the beginning.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.