So I migrated Todon.nl from Apache to Nginx. First I thought all went well, but now it seems nothing is streaming. In other words: the columns are not automatically updated. This all works fine under Apache. I followed the Production Guide. I can still switch to Apache if I want (stopping Nginx first) and than all works fine.
I’m using Nginx version 1.10.3 from the Debian jessie-backports). For reference: Apache is version 2.4.10. AND I’m using Mastodon 1.3.3 via Docker.
This is my Nginx configuration (note that I redirect todon.nl:80, www.todon.nl:80 and www.todon:443 to https://todon.nl):
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name todon.nl www.todon.nl;
# Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://todon.nl$request_uri; }
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.todon.nl;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/letsencrypt/live/todon.nl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/todon.nl/privkey.pem;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
# Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://todon.nl$request_uri; }
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name todon.nl;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/letsencrypt/live/todon.nl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/todon.nl/privkey.pem;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
keepalive_timeout 70;
sendfile on;
client_max_body_size 0;
root /home/todon/live/public;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
add_header Strict-Transport-Security "max-age=31536000";
add_header Content-Security-Policy "style-src 'self' 'unsafe-inline'; script-src 'self'; object-src 'self'; img-src data: https:; media-src data: https:; connect-src 'self' wss://example.com; upgrade-insecure-requests";
location / {
try_files $uri @proxy;
}
location ~ ^/(assets|system/media_attachments/files|system/accounts/avatars) {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri @proxy;
}
location @proxy {
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_set_header Proxy "";
proxy_pass_header Server;
proxy_pass http://127.0.0.1:3000;
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;
}
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_set_header Proxy "";
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;
}
For reference here is my Apache configuration (without the 80/www redirects):
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@localhost
ServerName todon.nl
ServerAlias www.todon.nl
DocumentRoot /home/todon/live/public/
Header add Strict-Transport-Security "max-age=31536000"
SSLCertificateFile /etc/letsencrypt/live/todon.nl/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/todon.nl/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ErrorLog ${APACHE_LOG_DIR}/todon_error.log
LogLevel error
CustomLog ${APACHE_LOG_DIR}/todon_access.log combined
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass /500.html !
ProxyPass /oops.png !
ProxyPass /api/v1/streaming/ ws://localhost:4000/
ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ErrorDocument 500 /500.html
ErrorDocument 501 /500.html
ErrorDocument 502 /500.html
ErrorDocument 503 /500.html
ErrorDocument 504 /500.html
</VirtualHost>
</IfModule>
Please advise?