# Redirect to discourse from a route in another domain

**URL:** <https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059>\
**Category:** Self-hosting\
**Created:** [2016年八月23日 12:01 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059 "2016-08-23T12:01:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mangelsnc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mangelsnc/32/60920_2.png) [@mangelsnc](https://meta.discourse.org/u/mangelsnc)\
**Post date:** [2016年八月23日 12:01 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/1 "2016-08-23T12:01:53Z")

</div>

Hi!

I need to put the discourse forum under a URL like `https://mydomain.com/forum`.

I have installed NGinx in the server which hosts discourse ([forum.mydomain.com](http://forum.mydomain.com)) , and redirected it to the discourse instance, something similar to this: [https://serversforhackers.com/video/installing-discourse-with-docker](https://serversforhackers.com/video/installing-discourse-with-docker) but without divide it in 3 containers.

In `mydomain.com` server I have the next configuration:

```plaintext
location /forum {
    rewrite ^/forum/(.*) /$1 break;
    proxy_pass https://forum.mydomain.com;
    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 `forum.mydomain.com` is:

```plaintext
upstream discourse {
    server 127.0.0.1:8080;
}

server {
    listen 80 default_server;
    server_name mydomain.com/forum;
    return 301 https://mydomain.com/forum$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;

    server_name mydomain.com/forum;
    merge_slashes on;

    charset utf-8;

    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;

    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 `https://mydomain.com/forum` 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.

Thanks!

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2016年八月23日 14:01 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/2 "2016-08-23T14:01:20Z")

</div>

The simplest thing to do is run discourse on its own domain like [forum.example.com](http://forum.example.com).

If you don’t want simple, try this

> [@Serve Discourse from a subfolder (path prefix) instead of a subdomain](https://meta.discourse.org/t/subfolder-support-with-docker/30507/):
>
> warning Discourse Official Statement about Subfolder setup We support subfolder setups for our hosted customers at the enterprise level and up. Due to heavy technical setup complexity we strongly recommend you do not use this setup unless you are very experienced in custom subfolder setups. It is critical you have a deep understanding of NGINX setup in the Discourse Docker container Secure original IP forwarding using custom headers in the proxy chain Rate limiting in front proxy server I…

---

<div class="post-metadata">

**Author:** ![mangelsnc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mangelsnc/32/60920_2.png) [@mangelsnc](https://meta.discourse.org/u/mangelsnc)\
**Post date:** [2016年八月24日 07:58 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/3 "2016-08-24T07:58:48Z")

</div>

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!

- [Subfolder support with Docker](https://meta.discourse.org/t/subfolder-support-with-docker/30507)
- [Discourse in a subfolder with multiple domains](https://meta.discourse.org/t/discourse-in-a-subfolder-multiple-servers-sharing-a-domain/30514/9)
- [Put Nginx in front of Discourse](https://serversforhackers.com/video/installing-discourse-with-docker)

Thanks for all!

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2019年二月26日 21:41 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/4 "2019-02-26T21:41:12Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2022年三月31日 17:36 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/5 "2022-03-31T17:36:30Z")

</div>



---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2022年三月31日 17:39 UTC](https://meta.discourse.org/t/redirect-to-discourse-from-a-route-in-another-domain/49059/6 "2022-03-31T17:39:45Z")

</div>


