Redirect to discourse from a route in another domain


I need to put the discourse forum under a URL like

I have installed NGinx in the server which hosts discourse ( , and redirected it to the discourse instance, something similar to this: but without divide it in 3 containers.

In server I have the next configuration:

location /forum {
    rewrite  ^/forum/(.*)  /$1 break;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

And the configuration of is:

upstream discourse {

server {
    listen 80 default_server;
    return 301$request_uri;

server {
    listen 443 default_server ssl;

    client_body_buffer_size     32k;
    client_header_buffer_size   8k;
    large_client_header_buffers 8 64k;

    root /var/www/discourse/public;
    index index.html index.htm;

    access_log /var/log/nginx/discourse.log;
    error_log  /var/log/nginx/discourse.log error;

    merge_slashes on;

    charset utf-8;

    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

    location ~ /.well-known {
       allow all;

    location / {
        include proxy_params;
        proxy_pass http://discourse;

        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

When I access to it redirects me to the forum, but fails loading CSS and shows the next error: Oops! That page doesn’t exist or is private.

There’s anyone in the room who has did this and succeed?

I’m open to any tutorial or simplest way to do this.


The simplest thing to do is run discourse on its own domain like

If you don’t want simple, try this


Thanks for the link @pfaffman!

I know there’s more simple to configure it on a subdomain, but is a requirement from my client.

Finally I use this posts to set up this, and finally it’s working!

Thanks for all!