Trailing slash and subfolder setup

(Ivan Rapekas) #1

Hi, I found that current configuration
a) sensible to end slash at user’s request and
b) returns incorrect location.
B may cause a problem for environments, where two web servers running at the same hardware, for example Drupal + Discourse behind the proxy. Incorrect URL-requests from users may be redirected to inexistent Drupal pages, and it is hard to handle all those requests by proxies config regexp.
To check if your configuration is ok, run two requests:

curl -v
curl -v

Both requests should work, they redirect to forum categories. If not, make the first change to the configuration at the topic:
a) add a slash at the end of your custom forum definition, i.e

location /forum/ {

Then check curl output, line ‘Location’. It should contain ‘forum’ word:

< Location:

Wrong configuration returns incorrect URL:

< Location:

This can be resolved by adding proxy_redirect to discourse upstream in /etc/nginx/conf.d/discourse.conf inside docker. Because this file is prepared during image bootstrap or rebuild, you need to add the following code to ‘run’ section of containers/app.yml:

- exec:
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/\/forum\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
       - sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf

where the definition line contains your server base_url and subfolder, it looks like:

proxy_redirect /forum/;

Sorry for sed, I am not a familiar to yaml syntax :confused:, appreciated to any remarks.

Current configuration free me of handling incorrect requests went to Discourse.

You may follow my post concerning Drupal SSO with Discourse behind a proxy here. Welcome for any suggestions on the subject.

Subfolder support with Docker
(Sam Saffron) #2

I am not following are any changes needed to: Subfolder support with Docker ? What changes do you recommend be made to the demo template there?

(Ivan Rapekas) #3

Hi @sam, sorry for my late response. I created the topic just for check purposes for those people who decided to install forum from subfolder. No need to make changes in template. Thanks!

(Sam Saffron) #4