Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# run this AFTER this script: https://gist.github.com/fragolinux/7229c1785652e4598d0bb61e50aa9093#file-nginx4apache
# to add reverse proxy functionalities to same system... this way you'll have:
# grafana, from ip:3000 to ip/grafana
# nodered and its dashboard, from ip:1880 to ip/nodered and ip/ui
# chronograf, from ip:8888 to ip/chronograf
# if you change Nginx default port, all the above will change accordingly (example: web on http://ip:81 then nodered on http://ip:81/nodered)
# reverse proxy for grafana, from ip:3000 to ip/grafana
sudo sed -i -e 's#;root_url = http://localhost:3000#root_url = http://localhost:3000/grafana/#g' /etc/grafana/grafana.ini
sudo sed -i -e '71i\\n location /grafana/ {\n proxy_pass http://localhost:3000/;\n }\n' /etc/nginx/sites-enabled/default
sudo systemctl restart nginx grafana-server
# to revert grafana on port 3000, change "http://localhost:3000/grafana/" to ";root_url = http://localhost:3000" in /etc/grafana/grafana.ini, then: sudo systemctl restart grafana-server
# reverse proxy for nodered and its dashboard, from ip:1880 to ip/nodered and ip/ui
sudo sed -i -e '71i\\n location /ui/ {\n proxy_pass http://localhost:1880/ui/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n proxy_set_header X-Real-IP $remote_addr;\n }\n' /etc/nginx/sites-enabled/default
sudo sed -i -e '71i\\n location /nodered/ {\n proxy_pass http://localhost:1880/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n proxy_set_header X-Real-IP $remote_addr;\n }' /etc/nginx/sites-enabled/default
sudo systemctl restart nginx
# nodered is not modified at all, it will still be available on its own port 1880 if you want, so no revert needed
# reverse proxy for chronograf, from ip:8888 to ip/chronograf
echo "BASE_PATH=/chronograf" | sudo tee -a /etc/default/chronograf > /dev/null
sudo sed -i -e '71i\\n location /chronograf/ {\n proxy_ignore_client_abort on;\n proxy_pass http://localhost:8888;\n proxy_set_header Host $host;\n }\n' /etc/nginx/sites-enabled/default
sudo systemctl restart nginx chronograf
# to revert, remove line "BASE_PATH=/chronograf" from /etc/default/chronograf, then: sudo systemctl restart chronograf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.