NGINX config problem ?
-
Folks,
I have a landing page (eg. mylandingpage.com) from where a link takes my users to my NodeBB which is hosted on a different server eg. some-ip-address:4567 .
After the browser travels to the NodeBB -page, I want the browser address to display <mylandingpage>.com/bb as opposed to some-ip-address:4567How do I solve this ?
Thanks in advance,
SD -
@assamese there is no htaccess file for NodeBB. You have to setup a reverse proxy to send requests for mylandingpage.com/bb to some-ip-address:4567
See docs here for instructions on setting up one https://docs.nodebb.org/en/latest/configuring/proxies.html
Also update the URL property in NodeBB's config.json to point to mylandingpage.com/bb
-
I have a landing page (eg. mylandingpage.com) from where a link takes my users to my NodeBB which is hosted on a different server eg. some-ip-address:4567 .
After the browser travels to the NodeBB -page, I want the browser address to display <mylandingpage>.com/bb as opposed to some-ip-address:4567How do I solve this ?
@pichalite - I did the changes to NINX conf, it does not seem to work.
Here is the relevant portion the nginx.conf file where <mylandingpage>.com is hosted -server_name <mylandingpage>.com;
location / {
root html;
index index.html index.htm;
}location /bb { 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://<ip-address-of-nodeBB-host>:4567/; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
My nginx version is: nginx/1.10.1
I changed the config.json file for NodeBB -
{
"url": "http://<mylandingpage>.com/bb",
..
}When the user navigates to http://<mylandingpage>.com/bb , the browser shows -
/ Not Found
You seem to have stumbled upon a page that does not exist. Return to the home page. -
When the user navigates to http://<mylandingpage.com>/bb , the browser screenshot looks like this -
-
@assamese Your location block is wrong.
/bb
will only match exactlyhttp://yourdomain.com/bb
and do a 301 redirect instead of a proxy_pass (see below)You need to change it to
= /bb
and add a/bb/
block so that it matches the whole directory correctly.Everything else is correct.
-
From the NGINX docs:
If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, or memcached_pass, then the special processing is performed. In response to a request with URI equal to this string, but without the trailing slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended. If this is not desired, an exact match of the URI and location could be defined like this:
location /user/ { proxy_pass http://user.example.com; } location = /user { proxy_pass http://login.example.com; }
This is worded a bit strangely imo, but what it is saying is, without the trailing slash or leading =, NGINX will ignore your proxy_pass directive.
-
@yariplus said in NGINX config problem ?:
If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, or memcached_pass, then the special processing is performed.
... this explains so much