# Is er een manier om DISCOURSE\_PORT naast DISCOURSE\_HOSTNAME op te geven?

**URL:** https://meta.discourse.org/t/is-there-a-way-to-specify-discourse-port-next-to-discourse-hostname/197950
**Category:** Self-hosting
**Created:** [23 juli 2021 om 07:04 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-discourse-port-next-to-discourse-hostname/197950 "2021-07-23T07:04:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vsile](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vsile/32/228636_2.png) [@vsile](https://meta.discourse.org/u/vsile)
#### Post date: [23 juli 2021 om 07:04 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-discourse-port-next-to-discourse-hostname/197950/1 "2021-07-23T07:04:14Z")

</div>

The target URL is **[https://discourse.example.com:9443](https://discourse.example.com:9443)**.  
We use reverse proxy (nginx) on **another server** with this config:

> **Спойлер**
>
> ```plaintext
> server {
> listen 9443 ssl;
> listen [::]:9443 ssl;
> 
> client_max_body_size 500m;
> 
> server_name discourse.example.com;
> 
> ssl_certificate /etc/ssl/certs/example.com.pem;
> ssl_certificate_key /etc/ssl/private/example.com.key;
> 
> location / {
> proxy_pass http://10.250.26.133:3080/;
> proxy_set_header Host $host;
> proxy_set_header X-Real_IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto $scheme;
> }
> }
> 
> ```

And this containers/app.yml:

> **Спойлер**
>
> ```plaintext
> templates:
> - "templates/postgres.template.yml"
> - "templates/redis.template.yml"
> - "templates/web.template.yml"
> - "templates/web.ratelimited.template.yml"
> # - "templates/web.ssl.template.yml"
> # - "templates/web.letsencrypt.ssl.template.yml"
> 
> expose:
> - "3080:80" # http
> - "443:443" # https
> 
> params:
> db_default_text_search_config: "pg_catalog.english"
> db_shared_buffers: "2048MB"
> 
> env:
> LC_ALL: en_US.UTF-8
> LANG: en_US.UTF-8
> LANGUAGE: en_US.UTF-8
> # DISCOURSE_DEFAULT_LOCALE: en
> 
> UNICORN_WORKERS: 8
> 
> DISCOURSE_HOSTNAME: discourse.example.com
> DISCOURSE_PORT: 9443 # <- this doesn't work
> 
> #DOCKER_USE_HOSTNAME: true
> 
> DISCOURSE_DEVELOPER_EMAILS: 'admin@example.com'
> 
> DISCOURSE_SMTP_ADDRESS: smtp.example.com
> DISCOURSE_SMTP_PORT: 587
> DISCOURSE_SMTP_USER_NAME: example-username
> DISCOURSE_SMTP_PASSWORD: "p@ssw0rd"
> DISCOURSE_SMTP_AUTHENTICATION: login
> DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
> DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
> DISCOURSE_SMTP_DOMAIN: example.com
> DISCOURSE_NOTIFICATION_EMAIL: discourse@example.com
> 
> LETSENCRYPT_ACCOUNT_EMAIL: me@example.com
> 
> volumes:
> - volume:
> host: /var/discourse/shared/standalone
> guest: /shared
> - volume:
> host: /var/discourse/shared/standalone/log/var-log
> guest: /var/log
> 
> hooks:
> after_code:
> - exec:
> cd: $home/plugins
> cmd:
> - git clone https://github.com/discourse/docker_manager.git
> - git clone https://github.com/discourse/discourse-oauth2-basic.git
> run:
> - exec: echo "Beginning of custom commands"
> - exec: echo "End of custom commands"
> 
> ```

I run ./launcher rebuild app.  
Then we have working url [https://discourse.example.com:9443](https://discourse.example.com:9443).

But

1. I couldn’t create admin user, because Discourse redirects me to URL without 9443 port.  
I had to create admin via console (`./launcher enter app` and then `rake admin:create`)

2. I couldn’t register any other user because the same reason.

3. I couldn’t connect with Gitea OAuth, because Discourse generates authorize URL with wrong redirect\_uri (missed 9443 port in URL)

Is there a way to specify DISCOURSE\_PORT next to DISCOURSE\_HOSTNAME?

---

<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: [23 juli 2021 om 13:30 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-discourse-port-next-to-discourse-hostname/197950/2 "2021-07-23T13:30:01Z")

</div>

You can’t access discourse on a web browser on a nonstandard port. See [How to set up Discourse on a server with existing Apache sites](https://meta.discourse.org/t/how-to-set-up-discourse-on-a-server-with-existing-apache-sites/30013). There is also a similar topic for nginx, but you just need the discourse part so this one should do it for you.

You also need to remove the ssl and let’s encrypt templates. Also, no need to expose 443.
