Watch out: My example enables HSTS. If your site goes live with this configuration, visitors that have seen it will refuse to use http for up to 2 years.
Ok, your last warning made me rather try the SSL config from the howto on running other websites on the same machine as Discourse.
I have a partial success: when I enter the old http domain, it routes me to the https site and shows the correct certificate. But there is no discourse, only a bad gateway (502).
Also, I had to stop apache2 for enabling the new nginx config, probably because apache2 was still listening on port 443. So now I assume I have to change the port in the in the apache config that listens to SSL to another port, to which nginx needs to forward requests to subfolders it cannot find. How do I configure nginx to do this?
EDIT: Reading through the SSL tutorial again reminded me I needed to add the ātemplates/web.ssl.template.ymlā which I deleted before. Rebuilding took for ever, because āGenerating DH parametersā - but in the end, still the same result (bad gateway). I bet I missed to enable SSL in some config fileā¦
You donāt actually needed that, as you want the outer nginx to handle SSL, not Discourseās internal nginx instance.
If my HSTS remark scared you off, you can just comment out the line that sets Strict-Transport-Security or decrease the number there to a low number of seconds.
Ah, I see. I will try with your config and āadd_header Strict-Transport-Security āmax-age=60;ā;ā then. Restarting nginx gave me complaints about the cert now, so I am rebuilding the app again without the web.ssl.template.yml. Another 6 long minutesā¦
Is it correct for the same reason I do not need to expose port 443 within the app.yml, because all the port handeling happens outside of the container, or could there be an error? I deleted the lines "expose: - ā80:80"ā "expose: - ā443:443"ā and and added ātemplates/web.socketed.template.ymlā instead (as explained in the howto on running other websites on the same machine as Discourse).
No improvement
The rebuild was unnecessary I guess, I should have adjusted the certificate paths. Now nginx starts correctly again, but still bad gatway on every domain and subfolder.
Do I need to configure SSL within my nginx sites enabled? Because that I havenāt done yetā¦
Yes, that sounds right. You want the Discourse (and its inner nginx instance) to simply listen to normal HTTP traffic on the socket, all handling of HTTPS (and sorting traffic between Discourse and Apache) is handled by the outer nginx.
(The configurations I posted above are slightly cleaned up versions of what I run in production.)
Iām a bit surprised by that. As long as you took the original port-80-configuration block and simply changed the port to 443 and added the relevant SSL options, nothing in the routing should change, i.e. you should see the same behavior, just over HTTPS instead of HTTP.
I think I got it. Embarassing to say, but I missed one path at your redirect block needed adjustment to my setup proxy_pass http://unix:/var/discourse/shared/vorkurs/nginx.http.sock:; must be proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
for me and it worksā¦ I have a secure discourse setup
But how do I forward the subfolders from my owncloud and dokuwiki to the apache?
That soulds like a good source of error for my problem. But if that is what the location part from the howto on Running other websites on the same machine as Discourse does, it is included:
ā¦included in the domain config within the nginx sites-enabled, not in the nginx/conf.d/discourse.conf. Replacing the locations part there with the one mentioned above there leeds to 404 and 502 all overā¦
Hm, not good. Your configuration is probably too specific to debug this remotely, so here is some more general advice:
You absolutely must configure your nginx to only route /forum/ traffic to Discourse, or it will ā surpsrise ā route all traffic to Discourse.
Because you followed the subfolder tutorial, Discourse now expects all requests to go to /forum/somewhere. Therefore, the outer nginx must not strip the /forum from the request, or Discourse will rightfully respond with 404 errors.
You can configure nginx to create quite extensive logs, which is key when debugging complex configurations
Also, your proxy_pass directive above looks fishy: nginx should speak HTTP to Discourse, not HTTPS.
Ok, you are right, it has allready become quite specificā¦
Thanks a lot for your patience and walking me through to this point. I will try to figure out the rest and hopefully get back to this thread with a positive result.
Thanks again for your effort, I got the main part working thanks to you and I learned a lot, which is worth even more to me
Of course, thatās a good idea and the least I can do!
I attached the files to this post, because the format seems to get broken by some characters inside the files. The ending .txt must of course be deleted, but I needed to add this to be allowed to upload the files hereā¦ and the capitalized parts of the code need to be changed to the individual system.
I think all the changes I made were in these files:
/etc/nginx/conf.d/discours.conf.txt (2.2 KB) EDIT: A typo in this filename I cannot change. It needs to be discourse.conf !