Moving Discourse to subdirectory caused all uploads to break

I recently bought an EV cert for my domain and I wanted to use it on both my main site and my forum. To solve this, I followed this guide and moved it to a subdirectory using a Varnish configuration.

The only noticeable problem was that this broke all current and new uploads. Existing uploads 404 from nginx, and new uploads fail with no error in sideqik or the error log.

You can view the site here: https://platinumcheats.net/forum/. It was moved from http://forum.platinumcheats.net/.

Anyone know what the deal is/how to fix? I understand that subdirectories are now officially supported in Discourse.

So poking around in the rails production log, I found this when uploading a file:

Started GET "/forum/uploads.json?client_id=xxx&authenticity_token=xxx" for xxx at 2015-08-27 02:15:10 +0000
ActionController::RoutingError (No route matches [GET] "/uploads.json")
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
Processing by ExceptionsController#not_found as JSON
  Parameters: {"client_id"=>"xxx", "authenticity_token"=>"xxx"}
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.3ms)

Did you check our topics in the howto category on subfolder?

https://meta.discourse.org/search?q=Subfolder%20category%3Ahowto

1 Like

I did. In the OP I stated I followed this howto:

Yeah looks like the issue is you changed to subfolder after the fact so all your uploads are in the old place. Any advice in this case @neil or @zogstrip?

Maybe we can update the howto so it covers this case as well.

Does the howto therefore assume a clean Discourse installation (e.g. not a rebuild)?

So I did a fresh install and restored from a backup. Everything is working perfectly now.

3 Likes

I don’t know why new uploads would have been failing…

To fix existing uploads you need to run the remap tool. Something like this:

bundle exec script/discourse remap '/uploads' '/forum/uploads'

2 Likes

And remap tool is covered in the existing howtos?

1 Like

Of course it is (because I just added it). The last section of this post mentions it.

3 Likes