sekai-soft / guide-nitter-self-hosting

A guide for self-hosting a Nitter instance
MIT License
154 stars 8 forks source link

Getting syntax error on running Nitter-only Docker #24

Open AdiPathak97 opened 2 months ago

AdiPathak97 commented 2 months ago

Followed the instructions here, but didn't add Instance RSS password at first in the .env file, due to which Nitter container kept exiting with an error. Fixed that to find it still kept exiting, here are the logs:

Dumping auth env...
Dumping custom path env...
Dumping redis connection env...
Dumping instance customization env...
Dumping instance guardian env...
Writing Procfile...
system | Tmux socket name: overmind-src-Py34SMgVDeToJZdIIHtoK
system | Tmux session ID: src
system | Listening at ./.overmind.sock
web    | Started with pid 17...
nginx  | Started with pid 18...
nginx  | Running gen_nginx_conf...
web    | Running auth...
nginx  | Launching nginx...
nginx  | nginx: [emerg] directive "if" has no opening "{" in /etc/nginx/conf.d/nitter.conf:6
nginx  | Exited with code 1
web    | Interrupting...
web    | Traceback (most recent call last):
web    |   File "/src/scripts/auth.py", line 211, in <module>
web    |     auth_res = auth(username, password, mfa_code)
web    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/src/scripts/auth.py", line 27, in auth
web    |     bearer_token_req = requests.post("https://api.twitter.com/oauth2/token",
web    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/requests/api.py", line 115, in post
web    |     return request("post", url, data=data, json=json, **kwargs)
web    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/requests/api.py", line 59, in request
web    |     return session.request(method=method, url=url, **kwargs)
web    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
web    |     resp = self.send(prep, **send_kwargs)
web    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
web    |     r = adapter.send(request, **kwargs)
web    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
web    |     resp = conn.urlopen(
web    |            ^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 789, in urlopen
web    |     response = self._make_request(
web    |                ^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 466, in _make_request
web    |     self._validate_conn(conn)
web    |   File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
web    |     conn.connect()
web    |   File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 615, in connect
web    |     self.sock = sock = self._new_conn()
web    |                        ^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 196, in _new_conn
web    |     sock = connection.create_connection(
web    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web    |   File "/usr/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
web    |     sock.connect(sa)
web    | KeyboardInterrupt
web    | Exited with code 0

I couldn't check the created nitter.conf file in the container because it keeps crashing. Any help would be highly appreciated!

Edit: Tiny detail I forgot to mention which may be relevant, I am using Podman instead of Docker, but podman compose uses docker compose under the hood. I find it unlikely for that to be the issue, but mentioning it for the sake of completeness.

KTachibanaM commented 1 month ago

To debug this you'll need to do those

  1. Clone my nitter repo https://github.com/sekai-soft/nitter
  2. In the scripts/nginx.sh file, replace the last line with sleep infinity
  3. Copy over your .env file
  4. Run docker compose exec -it nitter bash
  5. You can now inspect the /etc/nginx/conf.d/nitter.conf file and validate its content (I guess your RSS password contains special characters that cause nginx to not parse correctly)