From ccb8ac857330e1ad3aee37b340e5c6e242ac1dd6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 4 Feb 2017 00:34:31 +0100 Subject: Make the streaming API also handle websockets (because trying to get the browser EventSource interface to work flawlessly was a nightmare). WARNING: This commit makes the web UI connect to the streaming API instead of ActionCable like before. This means that if you are upgrading, you should set that up beforehand. --- docs/Running-Mastodon/Production-guide.md | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'docs/Running-Mastodon') diff --git a/docs/Running-Mastodon/Production-guide.md b/docs/Running-Mastodon/Production-guide.md index 76964d995..ff4427dd2 100644 --- a/docs/Running-Mastodon/Production-guide.md +++ b/docs/Running-Mastodon/Production-guide.md @@ -49,6 +49,22 @@ server { tcp_nodelay on; } + location /api/v1/streaming { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + + proxy_pass http://localhost:4000; + proxy_buffering off; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + tcp_nodelay on; + } + error_page 500 501 502 503 504 /500.html; } ``` @@ -162,6 +178,27 @@ Restart=always WantedBy=multi-user.target ``` +Example systemd configuration file for the streaming API, to be placed in `/etc/systemd/system/mastodon-streaming.service`: + +```systemd +[Unit] +Description=mastodon-streaming +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="NODE_ENV=production" +Environment="PORT=4000" +ExecStart=/usr/bin/npm run start +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target +``` + This allows you to `sudo systemctl enable mastodon-*.service` and `sudo systemctl start mastodon-*.service` to get things going. ## Cronjobs -- cgit