Several hard Apache ProxyPass rules needed under path + User Avatar Picture upload problem


We have a v2.4.0.beta2 +346 Discourse installation that was originally available at,

using Apache HTTP Server on Ubuntu that:

  • Redirects all HTTP requests to HTTPS
  • Manages by itself the SSL certificate (LetsEncrypt)
  • All requests were redirected by Proxy to using nginx http sock, so Discourse Docker ports 80 and 443 are disabled/unused

We did
./launcher enter app
rails c
[1] pry(main)> SiteSetting.force_https = true
=> true

To be extremely sure that everything was served in HTTPS (we had several errors if not)

And everything was working fine.

Then we decided to move the application (without touching DB or other stuff) under, so we edited the app.yml file like this:

  • DISCOURSE_HOSTNAME: <— Untouched, same as before

Then, to be extremely sure, we did:
./launcher stop app
./launcher destroy app
./launcher cleanup
./launcher rebuild app

Of course we also inserted in Apache config file the rules to correctly ProxyPass from /discourse to unix:/…/…/nginx.http.sock|http://localhost/discourse

After this, the application was of course online, but had a lot of problems:

  1. All static content stuff (plugins, assets, images, javascripts, uploads) weren’t available. After long debug sessions and non-fruitful web searches for letting them work we created some proxy rules in Apache to tunnel them to the root localhost path, without the /discourse prefix (eg. /disourse/plugins points to -> unix:/…/…/nginx.http.sock|http://localhost/plugins and so on)

  2. Some /uploads paths came from web pages without the /discourse prefix, so we needed to write another Apache proxy rule that moves from /uploads/ to unix:/…/…/nginx.http.sock|http://localhost/discourse/uploads

  3. Now the most strange thing: when the client sends requests containing /uploads/default/ or /discourse/uploads/default/ (static content) we need to follow the solution at point 1 described before and redirect them both to http://localhost/uploads/default/ (without the /discourse prefix), while other /uploads/ or /discourse/uploads/ requests that don’t contain /default prefix in path must be redirected to http://localhost/discourse/uploads/ (noticed that without the default path means that they are webservices calls)

With all these 9 proxy rules we inserted everything works fine again even under the /discourse path. But we found extremely strange that we needed to write all this stuff to let everything work again.
Are we doing something wrong?
Is there any other smart method to manage this situation?

=== EDIT ===
Forgot another thing that is maybe linked:
When the user tries to upload a custom picture to use as personal avatar, the upload goes OK and the miniature of the picture is correctly shown.

But when the Save changes button is pressed and the page is reloaded, the avatar comes back to the default user avatar image
Checking the produciton.log file, it shows that the error is Code 418.
Other picture uploads work well.

Thanks in advance for responses and for your amazing work!

1 Like

Subfolder installs are much more complex and not recommended.


Understood. Thanks

But we have no chances in this case so if no any other suggestion we will keep monitored the situation to see if there are other Proxy rules to manage.

Don’t you have any suggestion about the stuff of user upload? Looks kind of db storage problem, isn’t it?

1 Like