Topic Preview Broken (due to Google PageSpeed Module)

First I’d like to say thanks to all that work on Discourse. I’m a CS professor and I’ve used it for multiple courses. It’s far superior to Piazza, and I like being able to tell students that we’re using community-supported software. Keep up the good work.

I’ve put up the latest version of Discourse at Learn CS Online: An Introduction to Computer Science. I know that this is a subfolder install, and not completely supported, but it’s working fairly well. I’ve followed the instructions, and used my logs to hunt down some places where images weren’t being prefixed properly.

Except that the topic preview pane is not working. In a related problem, I can’t view the content of posts that have been queued for moderation. I can see an error in the Chrome developer console about “Cannot read property ‘getResponseHeader’ of undefined.” (I wanted to post the screenshot but only get one per topic and the Safari one is probably more revealing.)

On Safari the error is a bit more interesting:


I don’t see any errors in the server-side logs, but perhaps I’m not looking in the right place.

I’ve installed Let’s Encrypt certificates on cs125.cs.illinois.edu and have an nginx instance handling the encryption and reverse proxying to the Discourse container over a socket. I wonder if I need to add some Access-Control-Allow-Origin headers to my nginx configuration to get this to work?

Additional information: we’re on 1.9.0.beta7 and have no non-official plugins installed.

Any help tracking this down would be greatly appreciated, and will be a nice open source support success story to share with my students :smile:.

Have you had a read through?

https://meta.discourse.org/t/message-bus-doesnt-respect-subfolder/31119/3?u=sam

It’s set to /forum/. Should it be an absolute URL? And do I need to rebuild the container afterward? (I’m pretty sure I have rebuilt since changing that setting, since I had to fiddle with the rate limiting settings.)

I would set it to the absolute, no need to rebuild after changing it AFAIK.

No joy. Same problem.

Is there any other information I can provide to help you debug this?

Have you enabled the force_ssl site setting?

I just turned it on, and now Safari is generating a different problem:

This seems more similar to the problem that Chrome is reporting.

Does it work in How to use Discourse Safe Mode ?

Nope. Same problem with all boxes checked.

This does not look right: https://cs125.cs.illinois.edu/forum/assets/markdown-it-bundle-91aeb6600f2162d2794f12418867fef862f49ea60a788ebe93b131e36535bd08.js

It should look like this: https://meta.discourse.org/assets/markdown-it-bundle-91aeb6600f2162d2794f12418867fef862f49ea60a788ebe93b131e36535bd08.js

You have something messed up with the gzip compression setup on the proxy.

1 Like
  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript

Looks like there are some troubleshooting steps here:

I would recommend simply testing that single file with curl, fiddle with the config until you can curl that file above and get javascript out of it.

I get it actually, your NGINX server does not understand brotli.

You got to disable all brotli compression and rebuild. I think you do that by setting

env:
  COMPRESS_BROTLI: 0

OK—I have a starting point. I’ll work on this and get back to you.

Resolved! This turned out to be caused by Google’s PageSpeed module. I hadn’t enabled it within my location block, but I guess it’s enabled by default. Disabling it made the compression problem go away.

Thanks so much to @sam for his help! Much appreciated.

4 Likes