Discourse stopped working with 404 errors

Discourse was working great for a few months, then I wake up to find the page won’t load. Not sure if something changed in my system’s config or what. I tried sudo ./launcher rebuild app that didn’t seem to help. Then I tried sudo ./discourse-setup again, that got the site to at least load.

The problem is its loading a blank white page. When I check the inspector it returns pretty much all js files as 502 gateway errors. If I load the site on http instead of https, the errors are all 404 instead of 502.

I did a sudo ./laucher enter app and verified all the files exist - and they do, so I am at a complete loss. I was thinking perhaps an error in my nginx front end configuration, but I see nothing out of the ordinary.

Is there something I have forgotten or am I doing something incorrectly in my config or what could be going on?

my nginx.conf

server {
  listen      my.ip.address:80;
  server_name mydomain.name;
  error_log  /var/log/mydomain.name.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-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
      root           /path/to/mydomain.name/public_html;
      access_log     /var/log/mydomain.name.log combined;
      access_log     /var/log/mydomain.name.bytes bytes;
      expires        max;
      try_files      $uri @fallback;
    }
  }
.....

My nginx.ssl.conf

server {
  listen      my.ip.address:443;
  server_name mydomain.name;
  ssl         on;
  ssl_certificate      /path/to/ssl.mydomain.name.pem;
  ssl_certificate_key  /path/to/ssl.mydomain.name.key;
  error_log  /var/log/mydomain.name.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-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
      root           /path/to/mydomain.name/public_html;
      access_log     /var/log/mydomain.name.log combined;
      access_log     /var/log/mydomain.name.bytes bytes;
      expires        max;
      try_files      $uri @fallback;
    }
  }
....
1 Like

Are you out of disk space?

Try

 ./discourse-doctor

100% not out of space:

discourse doctor reports:

========================================
Discourse 2.2.0.beta8
Discourse version at domain.name: Discourse 2.2.0.beta8
Discourse version at localhost: NOT FOUND
==================== DNS PROBLEM ====================
This server reports NOT FOUND, but domain.name reports Discourse 2.2.0.beta8 .
This suggests that you have a DNS problem or that an intermediate proxy is to blame.
If you are using Cloudflare, or a CDN, it may be improperly configured.

This is why I was thinking some sort of issue with the nginx config. I am not using cloudflare or any CDN, which only leave the nginx front end config.

All DNS checking tools I haev tried say my DNS config is fine.

Ah. No. Discourse-doctor doesn’t know about your reverse proxy so that’s a red herring. Sorry. That’s no help.

Is the server overloaded? Recent update causes images to be reprocessed.

Not as far as I can see, load averages are low, bandwidth usage is low, memory usage is low, nginx usage is low - nothing unusual from what I can see.

Consider this problem sorted.

Apparently the control panel I use to manage my server has a bunch of different nginx setups, and I had somehow managed to switching it from a default proxy nginx configuration to a caching nginx configuration.

The minute I switched it back to a default proxy config, everything started working again. Only 3 days wasted trying to sort this and in the end it was completely unrelated to the server{} directives of nginx.

3 Likes