Node-Red: Nginx Reverse Proxy

This article  is a sequel of our Node-Red series of tutorials and focuses on proxying Node-Red instance with Nginx Web Server. There are numerous benefits of using this setup, especially the security features such as login rate limiting to avoid brute force attack. However, in this episode, we’ll just focus on the basic proxy setup for Node-Red using Nginx Web Server.

Nginx Configuration:

  • Navigate to the nginx configuration folder cd /etc/nginx/sites-available.
  • Create a new configuration file e.g. sudo nano nodred.
  • Add server block by copying the server block given below.
server {
  listen 80;
  server_name your_server_name;

  access_log /var/log/nginx/access.log;

  location / {
    proxy_pass http://localhost:1880;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}
  • Change the port in the Server Block, as desired.
  • Create a symbolic link for the virtual block created above sudo ln -s /etc/nginx/sites-available/nodered /etc/nginx/sites-enabled/.
  • Test nginx if configuration is correct sudo nginx -t. If everything is OK, then it will show the following message.
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  • Reload the Nginx to apply the changes sudo systemctl reload nginx.
  • Now you can access the Node Red via Nginx Proxy.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x