| SYSTEM INFORMATION | |
|---|---|
| OS type and version | Ubuntu 22.04 |
| Webmin version | 2.105 |
| Virtualmin version | 7.9.0 |
I saw it was asked a few times, so here’s a quick guide.
Install Discourse
From Discourse’s folder,
-
Don’t run
./discourse-setup -
cp ./samples/standalone.yml ./containers/app.yml -
Edit
app.yml: domain, email, SMTP credentials, etc.- Comment out the exposed ports:
# expose: # - "80:80" # http # - "443:443" # https - 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
- Comment out the exposed ports:
-
./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:
- Manage Virtual Server → Setup SSL Certificate → Let’s Encrypt tab
If Virtualmin uses Apache
-
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/ -
Save
If necessary, restart Apache:
systemctl restart apache2
If Virtualmin uses Nginx
-
Webmin → Servers → Nginx Webserver → Edit Configuration Files
-
Select the right vhost file in the top file selector
-
In the
server {block, add:location / { proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } -
Save & Close →
Apply Nginx Configuration
Configure Discourse
- Enable the force https setting
Now Discourse should be installed along Virtualmin and running.
Guides used for reference: Run other websites on the same machine as Discourse - Self-Hosting - Discourse Meta and Discourse behind reverse proxy and https - #3 by neounix - Installation - Discourse Meta