Moving Discourse to subdirectory caused all uploads to break

AI-generated summary

staticinvocation moved their Discourse forum to a subdirectory using Varnish to share an EV cert between sites, but this broke all uploads — existing ones 404’d and new uploads failed silently. After checking logs, they found a routing error for /uploads.json staticinvocation. codinghorror suggested reviewing existing subfolder howtos, which staticinvocation confirmed they followed. codinghorror noted the issue likely stems from moving to a subfolder after initial setup, meaning uploads remained in the old path, and asked for input from neil or zogstrip. staticinvocation questioned whether the guide assumes a clean install, then later reported success after a fresh install and restore from backup staticinvocation. neil explained that existing uploads require remapping via bundle exec script/discourse remap '/uploads' '/forum/uploads', and confirmed the remap tool is now documented in the howto’s final section neil. codinghorror suggested updating the howto to cover post-install subfolder moves.

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

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.

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'

And remap tool is covered in the existing howtos?

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