Disable SSL and add the proper template to create Nginx sock. It should look like this:
# base templates used; can cut down to include less functionality per container templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/web.template.yml"
# - "templates/web.ssl.template.yml" # remove - https will be handled by outer nginx
# - "templates/web.letsencrypt.ssl.template.yml" # remove -- https will be handled by outer nginx
- "templates/web.ratelimited.template.yml"
- "templates/web.socketed.template.yml" # <-- Added
./launcher rebuild app
Configure Virtualmin
Create Virtual Sever → yourdomain.com
Only tick Enable Nginx/Apache website
If it wasn’t done automatically, create a Let’s Encrypt certificate:
Webmin → Servers → Apache Webserver → Open both port 80 and 443 files
In the Port 80 file, add:
RewriteCond %{SERVER_NAME} =yourdomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
ProxyPassReverse / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
(don’t forget to replace yourdomain.com)
Save
In the Port 443 file, add:
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
ProxyPassReverse / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
It would be very interesting and appropriate if you thought about allowing the quick switch between Apache and Nginx installations with the installations already available in the Panels.
If someone wants to explain how to do this with Apache as well, that could be useful. Unfortunately, I know pretty much nothing about system administration and can’t do it myself.
Automatically trying to convert between Apache and nginx configs is complicated and risky; particularly going from Apache to nginx, since nginx is missing features found in Apache (no htaccess file support, for instance), so it’s easy for sites to break in ways we can’t automatically fix. I’d rather people just relax about web servers. It’s never the bottleneck, and both are fine. People should just use the one they’re comfortable with.
Googling “discourse proxy Apache” finds many results. This one is sane (many are not, I found one that included both HAProxy and nginx in addition to Apache…that’s three f’ing proxies!):
That thread also has stupid replies about Apache causing problems with Discourse, which is entirely fictional. It’s just proxying. Apache is a very fine proxy.
Proxying is a few lines of configuration. Virtualmin GPL now has the Proxy Paths feature, as well, which just came down from Virtualmin Pro in the most recent release. But, I don’t think the suggested “ProxyPreserveHost” option (which I guess is needed for the “block user and IP” feature of Discourse) is available in the Proxy Paths GUI. I’ll see if we can make that available in a future release.
My biggest problem was the cert process. If I do it in Apache, I have one browser that complained the images were coming from a different site. Just Firefox though.
I don’t remember the exact error but the images I think were just normal Discourse stuff. In this case I think I added some things for the large and small images.
When setting it up I ran into the problem of conflicting SSL. Some folks seem to have had success in getting Apache to defer to the Discourse container, some, not so much. It would seem preferable to let Discourse handle it all. But, I’m still playing with some sites when I have time. Right now, I have none.