Change default port 3000 on Rocket.Chat installed using Snap

12,142

Solution 1

You can define a rule in iptables

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000

and then save the rule by this command

sudo apt-get install iptables-persistent

Solution 2

Currently the Rocket.Chat snap doesn't have the option to change the port its listening on. In the near future we will be adding support for this, as well as to add ssl.

But for now our suggestion would be to use a reverse proxy like nginx in front of the snap.

If you decide to use nginx you can do the following:

Install nginx: sudo apt install nginx

Then edit /etc/nginx/sites-enabled/default with your favorite editor

and put the following contents in it:

# Upstreams
upstream backend {
    server 127.0.0.1:3000;
}

# HTTPS Server
server {
    listen 443;
    server_name your-domain.com;

    error_log /var/log/nginx/rocketchat.access.log;

    ssl on;
    ssl_certificate /etc/nginx/certificate.crt;
    ssl_certificate_key /etc/nginx/certificate.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE

    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;
    }
}

Replacing your-domain.com with your domain.

Once you save then restart nginx: sudo services nginx restart

Solution 3

This method worked for me.

root@sathish:/snap/rocketchat-server/580/bin# sudo snap run rocketchat-server.initcaddy
Replace /var/snap/rocketchat-server/580/Caddyfile with your own to customize reverse proxy

Edit the file

/var/snap/rocketchat-server/580/Caddyfile

Replace :8080 to :80

http://yourdomain:80
proxy / localhost:3000 {
  websocket
  transparent
}

Restart the service

sudo systemctl restart snap.rocketchat-server.rocketchat-caddy

Check the Port for confirmation

netstat -plnatu | grep :80
Share:
12,142
Admin
Author by

Admin

Updated on June 07, 2022

Comments

  • Admin
    Admin almost 2 years

    I have installed the Awsome Rocket.Chat on Ubuntu 16.04 using Snap, however i can no figure out how to change the server from running on http://DOMAIN:3000 to simply http://DOMAIN ..

    Thanks

  • alexw
    alexw over 6 years
    This answer is outdated - you can now simply use Caddy: rocket.chat/docs/installation/manual-installation/ubuntu/sna‌​ps/… Just note, you'll need to use Caddy on port 80 at first so it can present the acme challenge to LE to obtain an SSL cert. You may also want to disable the "restart on failure" behavior of Caddy to avoid hitting the LE rate limit. See stackoverflow.com/a/39202645/2970321
  • Aaron Ogle
    Aaron Ogle over 6 years
    You are right this answer is outdated. Caddy is now included and would be the recommended route