# Can't get Rocket.Chat to run behind nginx reverse proxy

**URL:** <https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691>\
**Category:** Community Support\
**Created:** [April 26, 2019, 5:43am UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691 "2019-04-26T05:43:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![LittleNo](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@LittleNo](https://forums.rocket.chat/u/LittleNo)\
**Post date:** [April 26, 2019, 5:43am UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/1 "2019-04-26T05:43:32Z")

</div>

### Description

Access to the Server thru the machine’s IP and default port (10.xx.xx.64:3000) works. However, when I open the URL from outside nginx reverse proxy the browser loads only the page name but nothing else (blank page).

### Server Setup Information

- Version of Rocket.Chat Server: 0.74.3
- Operating System: Ubuntu 18.04.2
- Deployment Method: snap
- Number of Running Instances: 1
- DB Replicaset Oplog:
- NodeJS Version:
- MongoDB Version:
- Proxy: nginx
- Firewalls involved: none

Even though I use my setup in LAN only I want to have SSL, therefore I wanted to use nginx as a reverse proxy using a self signed certificate. I setup nginx according to this instructions: [https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/](https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/)

According to this instructions: [https://rocket.chat/docs/installation/manual-installation/ubuntu/snaps/#how-do-i-change-other-environmental-variables-in-my-snap](https://rocket.chat/docs/installation/manual-installation/ubuntu/snaps/#how-do-i-change-other-environmental-variables-in-my-snap) I tried to set ROOT\_URL to the new URL (http\*s://10.xx.xx.64). I put a file with the line `OVERWRITE_SETTING_ROOT_URL=https://10.xx.xx.64` in `/var/snap/rocketchat-server/common`

Somewhere I found a hint that IP-Adress as URL is not supported (which is bad for me because I want to have access thru VPN as well where no DNS is available) so I also tried with the machines hostname as URL with the same result (http\*s://hostname)

Can anyone assist how to troubleshoot this?

- I had to put this \* in there due to limitation of new forum users only allowed to post 2 links

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [April 26, 2019, 11:00am UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/2 "2019-04-26T11:00:47Z")

</div>

First, what you want to do is non trivial. As a result you need to do is a lot of reading on DNS, SSL, Proxies and firewalls. Educating yourself will help a lot. The interwebs have a gazzilion pages on this sort of stuff.

Is nginx on the same machine as Rocket or a different machine? Can the nginx machine be accessed from the internet in general ?

Please post your nginx config file.

> Firewalls involved: none

REALLY??

> I want to have access thru VPN as well where no DNS is available

Exactly what do you mean??

---

<div class="post-metadata">

**Author:** ![LittleNo](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@LittleNo](https://forums.rocket.chat/u/LittleNo)\
**Post date:** [April 26, 2019, 2:49pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/3 "2019-04-26T14:49:18Z")

</div>

nginx conf:

```
upstream backend {
	server 127.0.0.1:3000;
}

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name srv-chat 10.8.189.64;
	location / {
		return 301 https://$server_addr$request_uri;
}	
}

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;
	server_name srv-name 10.xx.xx.64;
	client_max_body_size 200M;  
	# Certificates used
	ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
	ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
  

	ssl_protocols TLSv1.2;
#	ssl_protocols TLSv1.1;	
	# Cipher suite from https://cipherli.st/
	# Max. security, but lower compatibility 
	ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384';
 
	# Diffie-Hellman parameter for DHE ciphersuites, recommended 4096 bits
	#ssl_dhparam /etc/nginx/ssl/dhparams.pem;
  	ssl_dhparam /etc/nginx/dhparam.pem;

	ssl_ecdh_curve secp521r1:secp384r1:prime256v1;
 
	# Server should determine the ciphers, not the client
	ssl_prefer_server_ciphers on;
  
	# OCSP Stapling
	# fetch OCSP records from URL in ssl_certificate and cache them
	ssl_stapling on;
	ssl_stapling_verify on;
	
	
	# SSL session handling
	ssl_session_timeout 24h;
	ssl_session_cache shared:SSL:50m;
	ssl_session_tickets off;
 
	add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload;" always;
	add_header X-Content-Type-Options "nosniff" always;
	add_header X-XSS-Protection "1; mode=block" always;
	add_header X-Robots-Tag none always;
	add_header X-Download-Options noopen always;
	add_header X-Permitted-Cross-Domain-Policies none always;
	add_header Referrer-Policy no-referrer always;
 
   
	location = / {
		proxy_pass http://backend/;
		proxy_http_version 1.1;
   	proxy_set_header Upgrade $http_upgrade;
   	proxy_set_header Connection "upgrade";
   	proxy_set_header Host $http_host;
   	proxy_set_header X-Real-IP $remote_addr;
   	proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
   	proxy_set_header X-Forward-Proto http;
   	proxy_set_header X-Nginx-Proxy true;
   	proxy_redirect off;
   	}	
}

```

nginx is on the same machine. For now this is only a test setup and the whole machine cannot be reached from the internet. So yes, really no firewall for now.

Forget about the VPN thing because it is not in use here and not relevant for this issue.

---

<div class="post-metadata">

**Author:** ![speedy01](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@speedy01](https://forums.rocket.chat/u/speedy01)\
**Post date:** [April 26, 2019, 5:06pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/4 "2019-04-26T17:06:02Z")

</div>

> [@LittleNo](#):
>
> proxy\_pass [http://backend/](http://backend/);

try removing the trailing slash

---

<div class="post-metadata">

**Author:** ![LittleNo](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@LittleNo](https://forums.rocket.chat/u/LittleNo)\
**Post date:** [April 26, 2019, 5:22pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/5 "2019-04-26T17:22:46Z")

</div>

I did now, with the same result

---

<div class="post-metadata">

**Author:** ![speedy01](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@speedy01](https://forums.rocket.chat/u/speedy01)\
**Post date:** [April 26, 2019, 7:16pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/6 "2019-04-26T19:16:11Z")

</div>

are you able to telnet to the port you are trying to server? if not, than you issue may be something else…ie software/os firewall

---

<div class="post-metadata">

**Author:** ![LittleNo](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@LittleNo](https://forums.rocket.chat/u/LittleNo)\
**Post date:** [April 26, 2019, 9:43pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/7 "2019-04-26T21:43:33Z")

</div>

the browser shows the page title, so a no communication issue is not the case

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [April 27, 2019, 12:51pm UTC](https://forums.rocket.chat/t/cant-get-rocket-chat-to-run-behind-nginx-reverse-proxy/3691/8 "2019-04-27T12:51:52Z")

</div>

Use a much much simple nginx conf to start with.

Here’s my basic one for testing.

> <https://gist.github.com/reetp/e6bd562d85cc40ba4beba28f98678290>

The problem is going to be your nginx conf and probably websockets. It’s always the same ☹
