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 http://example.com/forum/c/
curl -v http://example.com/forum/c
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: http://example.com/forum/categories
Wrong configuration returns incorrect URL:
< Location: http://example.com/categories
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:
cmd:
- sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
- sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/forum\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
- sed -i '/no-referrer-when-downgrade/a proxy_redirect http:\/\/example.com\/ \/forum\/;' /etc/nginx/conf.d/discourse.conf
where the definition line contains your server base_url and subfolder, it looks like:
proxy_redirect http://example.com/ /forum/;
Sorry for sed, I am not a familiar to yaml syntax , 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.