Installed discourse on a server that already runs a webserver, domain just redirects to subdomain

Hi!
I just set up discourse and then followed this guide.
My subdomain for the forum is forum.example.com.

However, when I go to example.com, I just get redirected to forum.example.com

Here is my Namecheap DNS setting:

This is my outer nginx config:

wordpress.conf (my main site):

server {
  listen 80;
  #listen 443 default ssl;

  server_name snapecraft.net;
  root /var/www/html;

  #ssl_certificate /etc/nginx/ssl/mydomain.crt;
  #ssl_certificate_key /etc/nginx/ssl/mydomain.key;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log error;

  index index.php index.phtml index.html;

  location / {
        try_files $uri $uri/ /index.php?$args;
        if (-f /var/ErrorPages/maintenance.html) {
            return 400;
        }
        # add one directive for each http status code
        error_page 400 /ErrorPages/maintenance.html;
        error_page 404 /ErrorPages/404.html;
        error_page 503 /ErrorPages/503.html;
    }

    # redirect the virtual ErrorPages path the real path
    location /ErrorPages/ {
        alias /var/ErrorPages/;
        internal;
    }


#  location ~ \.php$ {
#    fastcgi_pass 127.0.0.1:9000;
 #   fastcgi_split_path_info ^(.+\.php)(/.+)$;
  #  fastcgi_intercept_errors on;
  #  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 #   include /etc/nginx/fastcgi_params;
#
#  }

    location ~ [^/]\.php(/|$) {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_intercept_errors on;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include /etc/nginx/fastcgi_params;

  }



}

discourse.conf (Config for the forum):

server {
    listen 80; listen [::]:80;
    server_name forum.snapecraft.net;  # <-- change this

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;  listen [::]:443 ssl http2;
    server_name forum.snapecraft.net;  # <-- change this

    ssl on;
    ssl_certificate      /var/discourse/shared/standalone/ssl/forum.snapecraft.net.cer;
    ssl_certificate_key  /var/discourse/shared/standalone/ssl/forum.snapecraft.net.key;
    ssl_dhparam          /var/discourse/shared/standalone/ssl/dhparams.pem;
    ssl_session_tickets off;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;

    http2_idle_timeout 5m; # up from 3m default

    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 https;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Thanks a bunch in advance! Any help is highly appreciated!

What I can guess is that there is something wrong with your wordpress configuration (It looks very customized with those error pages etc.)

while trying to access your wordpress, I get

The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies

Page location is http://snapecraft.net/en/home-2/

This is what I get when I try to curl that link:

curl -I http://snapecraft.net/en/home-2/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.15.8
Date: Sun, 27 Jan 2019 15:22:11 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: pll_language=en; expires=Mon, 27-Jan-2020 15:22:11 GMT; Max-Age=31536000; path=/
Location: http://snapecraft.net/home-2/

forum loads fine.

Any chance your primary site is running without ssl as well?

Yes, my wordpress site is running without SSL.
My website is bi-lingual (German & English) and detects your browser’s language. The german wordpress site works fine after clearing the cache.
Just the english page doesn’t work what is kind of weird. Do you know what is the issue?

When we’re at it, how would that SSL transition work?

This is the redirection loop that your site is stuck in.

1 Like

Ok, this is weird.

I just bought the domain and previously we had this domain: snapecraft.ddns.net

I changed the domain in wp-config and used a plugin.

Which Plugin? can you try disabling it for diagnostics?

It’s called ‘DB Migrate’

So I guess the old domain still remains in certain parts of the DB

My multi-Language plugin is called ‘PolyLang’

I can’t help you much with wordpress here,
You can maybe try disabling all the plugins in wordpress (by moving them out of the /wp-contents/plugin folder) and then trying to see if it fixes it? or maybe hire someone to fix your wordpress.

1 Like

Nevermind, I just had to change the polylang settings :smiley:
Thank you very much for your help!

1 Like

Glad to hear your issue is fixed :slight_smile:

1 Like

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