Skip to content

Instantly share code, notes, and snippets.

@mariotaku
Last active March 2, 2024 10:18
Show Gist options
  • Save mariotaku/f1d61ec9cded3b0ed01f049bb5ddd840 to your computer and use it in GitHub Desktop.
Save mariotaku/f1d61ec9cded3b0ed01f049bb5ddd840 to your computer and use it in GitHub Desktop.
Twitter reverse proxy configuration for Nginx
Settings on Twidere:
API URL Format: https://your-host/[DOMAIN.]twitter.com/
Uncheck "Same OAuth signing URL"
Uncheck "No verion suffix"
Password login recommended.
upstream twitter_userstream {
server userstream.twitter.com:443;
keepalive 300;
}
server {
listen 443 ssl spdy;
server_name [YOUR-SERVER-NAME-HERE];
ssl_certificate [/path/to/ssl/certificate/cert.pem];
ssl_certificate_key [/path/to/ssl/certificate/privkey.pem];
location ~ ^/userstream\.twitter\.com/(.*) {
resolver 8.8.8.8;
proxy_pass https://twitter_userstream/$1$is_args$args;
proxy_cookie_domain twitter.com $server_name;
proxy_buffering off; # Turn off buffer in order to get stream as-is
proxy_set_header Host userstream.twitter.com;
proxy_http_version 1.1; # This was necessary!!!
}
location ~ ^/([\w\d-_]+)\.twitter\.com/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.twitter.com/$2$is_args$args;
proxy_cookie_domain twitter.com $server_name;
}
location / {
root [/path/to/welcome/file];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment