Advanced Setup and Administration

(Arpit Jalan) #1

Here are some of the more advanced Discourse setup and administration questions we see:

How can I enable Cross-origin Resource Sharing with Docker?

Modify these settings in app.yml file:


Now rebuild the container:

cd /var/discourse
./launcher rebuild app

This will enable Cross-origin Resource Sharing on your Discourse instance.

How can I use Nginx alongside the Discourse Instance?

Change the port the docker container binds to in app.yml to something other than 80; and then in your nginx install set up http forwarding to direct to this alternate port. Follow the steps for installing normally until you reach ./launcher bootstrap app

  • Edit app.yml to bind to a port other than port 80 externally. Pick something that is not in use (maybe 4578?)
 - "4578:80"   # fwd host port 4578   to container port 80 (http)
  • Continue with the steps above (bootstraping, starting), and verify that you can see discourse on the alternate port. Use your server IP as above, and add in the port you chose. For example: if your server IP was

  • Configure your current nginx install to proxy_pass to the docker container. Here is an example of something you can include in sites-enabled.

  • Remember to restart your external nginx.

How can I change Upload Maximum value?

Add this text to your app.yml after - exec: echo "Beginning of custom commands":

  - replace:
      filename: "/etc/nginx/conf.d/discourse.conf"
      from: /client_max_body_size.+$/
      to: client_max_body_size XXm;

Change XX to any amount of megabytes you want. Then rebuild your container with

./launcher rebuild app

How can I completely wipe my Discourse Instance?

If you want to destroy your entire Discourse instance data, and want to start fresh:

rm -rf /var/discourse/shared*

I can’t upgrade my Docker based Discourse instance. Any workaround?

Try doing this:

cd /var/discourse
git pull
./launcher rebuild app

How can I upgrade Docker on my Ubuntu server?

Run these commands:

apt-get update
apt-get dist-upgrade
apt-get upgrade lxc-docker

How can I set-up automatic security updates in Ubuntu?

Run this command:

dpkg-reconfigure -plow unattended-upgrades

How can I set-up email notification of other Ubuntu updates?

apt-get install sendmail
apt-get install apticron
nano /etc/apticron/apticron.conf

(change EMAIL to

My Docker container is low on Disk Space. How can I clean up old Docker containers?

A quick way to recover space

apt-get autoclean && apt-get autoremove -y
./launcher cleanup

How to scale discourse?
Advanced Troubleshooting with Docker
Configuring nginx to work alongside Discourse
Getting Discourse installed on OVH VPS
Can I get a Discourse/JSON example?
Using Azure to host a docker based Discourse instance
User pictures broken after latest update (v1.5.0.beta5)
Configuring nginx to work alongside Discourse
Access-Control-Allow-Origin on SSO url by external ID
Advanced Troubleshooting with Docker
What are the risks of enabling Cross-origin resource sharing (DISCOURSE_ENABLE_CORS)
DELETE and PUT request response ERROR
(Jeff Atwood) #5

I dunno, I feel like this information is kind of a duplicate of




… isn’t it?

I apologize, but I’m not a big fan of “let’s create a random list of things people might be interested in”.

(Sam Saffron) #6

I think some of this is missing from guides, perhaps @techapj can create a pr to roll it in.

(Rahul Bansal) #9

I noticed this. I am wondering how database is preserved? Postgres and user uploads are stored inside container, right?

How they are getting preserved?

Config changes lost on docker container restart
(Kane York) #10

That’s covered over here:

Changing container files
(M Zain Damlag) #11

Hello there, I developed a small function to allow both sides SSO, It’s working good locally

But when I installed discourse in my server, I could access my container files and change it, but these changes didn’t work and if i rebuild the app all changes disappear

who can I do changes in the source code and docker build it ?

When I restarted the app every thing goes ok but the changes didn’t be permanent If i rebuild the app after installing an plugin.

(Kane York) #12

(M Zain Damlag) #13

@sam I read the topic but I didn’t understand how to save changed from being removed if a rebuilt happened ?

and I added a function to session controller, but when I access it I got “The page you requested doesn’t exist or is private.”

(Jens Maier) #14

Simply put, you don’t.

Set up a development environment, code and test your modifications and wrap them into a plugin. Then set up some code hooks in your app.yml to install that plugin and rebuild.

(M Zain Damlag) #15

Is there a tutorial/documentation how to wrap the modifications in main controllers into plugin ?