From e317ac9b9247e164269761e24d626843747dff37 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 18 Nov 2022 19:36:48 +0000 Subject: [PATCH] nitter: enable twitter gateway --- Makefile | 1 + env.production | 1 + nitter.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ nitter/Dockerfile | 10 ++++++++++ nitter/nginx.conf | 33 +++++++++++++++++++++++++++++++++ nitter/nitter.conf | 45 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 133 insertions(+) create mode 100644 nitter.yaml create mode 100644 nitter/Dockerfile create mode 100644 nitter/nginx.conf create mode 100644 nitter/nitter.conf diff --git a/Makefile b/Makefile index fce2e70..7fdb804 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ MODULES += matrix MODULES += nextcloud MODULES += mobilizon MODULES += gitea +MODULES += nitter #MODULES += pixelfed include env.production diff --git a/env.production b/env.production index 6b1e159..d4f04f8 100644 --- a/env.production +++ b/env.production @@ -20,6 +20,7 @@ MATRIX_HOSTNAME=matrix MOBILIZON_HOSTNAME=events PIXELFED_HOSTNAME=pixelfed PROMETHEUS_HOSTNAME=metrics +NITTER_HOSTNAME=nitter AUTH_URL=https://${KEYCLOAK_HOSTNAME}.${DOMAIN_NAME}/realms/${REALM}/protocol/openid-connect/auth TOKEN_URL=https://${KEYCLOAK_HOSTNAME}.${DOMAIN_NAME}/realms/${REALM}/protocol/openid-connect/token diff --git a/nitter.yaml b/nitter.yaml new file mode 100644 index 0000000..ddf2156 --- /dev/null +++ b/nitter.yaml @@ -0,0 +1,43 @@ +version: "3" + +services: + nitter: +# image: zedeus/nitter:latest + build: + context: nitter + dockerfile: Dockerfile + container_name: nitter + volumes: + - ./nitter/nitter.conf:/src/nitter.conf.template:ro + depends_on: + - nitter-redis + restart: unless-stopped + healthcheck: + test: wget -nv --tries=1 --spider http://127.0.0.1:8080/Jack/status/20 || exit 1 + interval: 30s + timeout: 5s + retries: 2 + env_file: + - ./env.production + environment: +# - DOMAIN_NAME=${DOMAIN_NAME} +# - NITTER_HOSTNAME=${NITTER_HOSTNAME} + - NITTER_SECRET=${NITTER_CLIENT_SECRET} + + nitter-redis: + image: redis:6-alpine + container_name: nitter-redis + command: redis-server --save 60 1 --loglevel warning + volumes: + - ./data/nitter/redis:/data + restart: unless-stopped + healthcheck: + test: redis-cli ping + interval: 30s + timeout: 5s + retries: 2 + + # add the nitter nginx configuration into the nginx volume + nginx: + volumes: + - ./nitter/nginx.conf:/etc/nginx/templates/nitter.conf.template:ro diff --git a/nitter/Dockerfile b/nitter/Dockerfile new file mode 100644 index 0000000..22ae4fc --- /dev/null +++ b/nitter/Dockerfile @@ -0,0 +1,10 @@ +# +# Use the official image, but add envsubst so that we can use +# variable names in the configuration file. +# +FROM zedeus/nitter:latest +RUN apk --no-cache add gettext + +ENTRYPOINT ["/usr/bin/env"] +CMD ["/bin/sh", "-c", "envsubst < ./nitter.conf.template > ./nitter.conf && exec ./nitter"] +#CMD ["/bin/sh", "-c", "echo hello ; sleep 60" ] diff --git a/nitter/nginx.conf b/nitter/nginx.conf new file mode 100644 index 0000000..6627d79 --- /dev/null +++ b/nitter/nginx.conf @@ -0,0 +1,33 @@ +server { + server_name ${NITTER_HOSTNAME} ${NITTER_HOSTNAME}.${DOMAIN_NAME}; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + #include /etc/nginx/mime.types; + #default_type application/octet-stream; + + client_max_body_size 160m; + gzip on; + gzip_disable "msie6"; + + proxy_read_timeout 1800s; + + # required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486) + chunked_transfer_encoding on; + + location / { + proxy_pass http://nitter:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + listen 443 ssl; + ssl_certificate /etc/letsencrypt/live/${DOMAIN_NAME}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/${DOMAIN_NAME}/privkey.pem; + include /etc/nginx/includes/options-ssl-nginx.conf; + include /etc/nginx/includes/challenge.conf; + ssl_dhparam /etc/nginx/includes/ssl-dhparams.pem; +} diff --git a/nitter/nitter.conf b/nitter/nitter.conf new file mode 100644 index 0000000..9ba944c --- /dev/null +++ b/nitter/nitter.conf @@ -0,0 +1,45 @@ +[Server] +address = "0.0.0.0" +port = 8080 +https = false # disable to enable cookies when not using https +httpMaxConnections = 100 +staticDir = "./public" +title = "nitter" +hostname = "${NITTER_HOSTNAME}.${DOMAIN_NAME}" + +[Cache] +listMinutes = 240 # how long to cache list info (not the tweets, so keep it high) +rssMinutes = 10 # how long to cache rss queries +redisHost = "nitter-redis" +redisPort = 6379 +redisPassword = "" +redisConnections = 20 # connection pool size +redisMaxConnections = 30 +# max, new connections are opened when none are available, but if the pool size +# goes above this, they're closed when released. don't worry about this unless +# you receive tons of requests per second + +[Config] +hmacKey = "${NITTER_SECRET}" # random key for cryptographic signing of video urls +base64Media = false # use base64 encoding for proxied media urls +enableRSS = true # set this to false to disable RSS feeds +enableDebug = false # enable request logs and debug endpoints +proxy = "" # http/https url, SOCKS proxies are not supported +proxyAuth = "" +tokenCount = 10 +# minimum amount of usable tokens. tokens are used to authorize API requests, +# but they expire after ~1 hour, and have a limit of 187 requests. +# the limit gets reset every 15 minutes, and the pool is filled up so there's +# always at least $tokenCount usable tokens. again, only increase this if +# you receive major bursts all the time + +# Change default preferences here, see src/prefs_impl.nim for a complete list +[Preferences] +theme = "Nitter" +replaceTwitter = "${NITTER_HOSTNAME}.${DOMAIN_NAME}" +replaceYouTube = "piped.kavin.rocks" +replaceReddit = "teddit.net" +replaceInstagram = "" +proxyVideos = true +hlsPlayback = false +infiniteScroll = true