Software IT-Consulting und Coaching

Running Gitea behind Plesk Onyx

Just install Gitea as proposed in documentation https://docs.gitea.io/en-us/install-from-binary/

I changed the execution port to 3001, because of an existing, running NodeJS application on port 3000.

Now move to Hosting settings of plesk. I first tried to serve the contents with Nginx. But the location / is already defined by plesk internally. Even if I managed to add another root location with proxy_pass to localhost:3001, some links within Gitea are broken with 404 (e.g. dashboard or branches). Sub-locations were served as intended. The problem is: Nginx always try to serve an index file on root directory requests (which is the default rule specified Plesk, before custom Nginx config is appended.)

So a request to https://my-git.example.com is served to https://localhost:3001/index.html. Gitea cannot serve this and no Dashboard is shown.

The absence of Dashboard is not a huge problem, but it’s still annoying. That’s why I gave Apache a try and putting Nginx to proxy mode.

I specified the following simple rewrite rule to HTTPS:
RewriteEngine On
RewriteRule ^(.*)$ http://localhost:3001$1 [P]

It makes my day. All requests are just forwarded to Gitea as wished, because no index files are appended automatically. The rule just appends the whole URI as is to http://localhost:3001 acting in reverse-proxy mode ([P])