Topic Preview Broken due to Google PageSpeed Module


(Geoffrey Challen) #1

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 CS 125. 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:.


(Sam Saffron) #2

Have you had a read through?


(Geoffrey Challen) #3

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.)


(Sam Saffron) #4

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


(Geoffrey Challen) #5

No joy. Same problem.

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


(Sam Saffron) #6

Have you enabled the force_ssl site setting?


(Geoffrey Challen) #7

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

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


(Sam Saffron) #8

Does it work in How to use Discourse Safe Mode ?


(Geoffrey Challen) #9

Nope. Same problem with all boxes checked.


(Sam Saffron) #10

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

It should look like this: 404 Not Found

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


(Geoffrey Challen) #11
  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

(Sam Saffron) #12

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.


(Sam Saffron) #13

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

(Geoffrey Challen) #14

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


(Geoffrey Challen) #15

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.


(Joshua Rosenfeld) #16