How to change 'localhost:4567' to actual domain name!!
-
Hi,
I need to change the "localhost:4567" with my actual domain name.
Config.json File:
{
"url": "http://localhost:4567",
"secret": "d20000e7-bd69-47ed-b915-e19b270f7ae8",
"database": "redis",
"redis": {
"host": "127.0.0.1",
"port": "6379",
"password": "",
"database": "1"
}
}Ubuntu server file:
server {
listen 80;server_name forum.example.org; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:4567/; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
}
How can I change it to my "domain name" instead of "localhost:4567"?Thanks!!
-
Change localhost:4567 to yourdomain.com:4567. Then in nginx set a reverse proxy from yourdomain.com to your servers ip:4567
Will post my configuration in about 10 minutes for you.
-
Bit late, apologies,
server { listen 80; server_name 35hz.co.uk; location / { allow all; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:4567/; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
{ "secret": "Probably best not to show your secret", "database": "redis", "redis": { "host": "127.0.0.1", "port": "6379", "password": "Or your Database Password", "database": "0" }, "url": "http://35hz.co.uk" }
Just change 35hz.co.uk for your domain. And make sure your DNS points to your servers IP address via an A name record. Or you'll be doing the above for no reason.
Also set a password in your redis.conf file with /etc/redis/. Make it long and difficult too. Just in case. Mines 52 characters. Pretty sure @Ted has his at about 499 characters.
-
@gvimlan said:
Why are we using reverse proxy?
Because a NodeBB server use 4567 as default and it is bound to all of the interfaces in a host computer. You may connect to server by http://ip:4567 probably. Nginx is needed to redirect connection to your server from port yourdomain.com:80 to localhost:4567.
-
@gvimlan The DNS resolves your domain name (e.g.
example.org
) with your server IP address (e.g.127.0.0.1
). The reverse proxy listens for that request (e.g.I am @gvimlan's computer, I'd like to access example.org at 127.0.0.1 please
), and transparently forwards (or proxies) that request to NodeBB (e.g.Okay, example.org is actually listening on port 4567, so I'll talk to 127.0.0.1:4567 on your behalf
)Hopefully that made it clearer!
-
You'll probably want to create a new file so that everything is organized. I have one file per site, that makes it easy to separate different configurations all on the same server.
$ cd /etc/nginx/sites-available $ nano nodebb # paste the nginx config here $ cd ../sites-enabled && ln -s ../sites-available/nodebb
The third command creates a symbolic link to the actual configuration (in
sites-available/
) from the folder that nginx actually checks (sites-enables/
). This sort of setup comes in handy if you ever want to temporarily disable a site, just simply remove the symbolic link! -
Yes, you'll need it in your config file. Just replace redis with mongo phrase or use setup to generate config.json.