Skip to content

ROOT_URL not set after many install problems, errors, 404s #19972

Closed
@TokisanGames

Description

@TokisanGames

Description

The goal: Set up gitea in a subdirectory on my VPS under https, eg https://example.com/git/ . No docker.

I had a ton of issues setting up a reverse proxy under SSL and a subdirectory. I read through countless issues, but couldn't find a complete working example that worked for me. Also the reverse proxy guide did not work for me. I either got broken images and 404 errors. I think I have it mostly working now, but I have one persistent error on screen, and what is probably a small bug appearing in my logs.

Current issues

I've made an admin, a user, an organization, and an empty repo. I can browse around the system. It seems like things work so far.

  1. I can't get rid of this error message. It appears at the top of every screen in red, constantly. ROOT_URL is set.
Your ROOT_URL in app.ini is undefined but you are visiting https://example.com/git/
You should set ROOT_URL correctly, otherwise the web may not work correctly.
  1. I get errors like this in my logs and the 404s appear in my browser console. :
2022/06/14 20:57:49 ...s/context/context.go:314:PlainTextBytes() [E] PlainTextBytes: Not found.
2022/06/14 20:57:49 Completed GET /repo/search?count_only=1&uid=2&team_id=0&q=&page=1&mode= 404 Not Found in 2.741671ms
2022/06/14 20:57:49 Completed GET /repo/search?sort=updated&order=desc&uid=2&team_id=0&q=&page=1&limit=15&mode=&archived=false 404 Not Found in 2.64007ms

These appear on https://example.com/git/ when logged in and looking at my dashboard. Likely because there are no general repos, only one within an organization and rather than checking for that, it is queried anyway.

Set up

I downloaded a prebuilt package that did not come with static assets, so I built those from the source repo but could not figure out where to put them so they could be served by the embedded server. I also couldn't enable enough logging to see the complaints on individual files. Enabling access logs and trace level logs in app.ini didn't actually give me per asset logs and errors.

Nginx config
I placed the assets in /var/lib/gitea/public, so css, img, js are directly under that folder.
server {
    server_name example.com www.example.com;
    listen 443 default_server ssl http2;
    listen [::]:443 default_server ssl http2;

    ssl_certificate /etc/ssl/local/example.com-bundle.crt;
    ssl_trusted_certificate /etc/ssl/local/example.com-bundle.crt;
    ssl_certificate_key /etc/ssl/local/example.com.key;
    include snippets/ssl-intermediate.conf;

    root /var/www/example/www;
    index index.php;
    access_log /var/www/example/logs/access.log;
    error_log /var/www/example/logs/error.log ;

    include snippets/restrictions.conf;

    # Gitea
    location ^~ /git/assets/ {
        root        /var/lib/gitea/public;
        rewrite     ^/git/assets/(.*)$ /$1 break;
        access_log  /var/lib/gitea/log/nginx_access.log;
        error_log   /var/lib/gitea/log/nginx_error.log;
        try_files   $uri =404;
    }

    location /git/ {
        access_log  /var/lib/gitea/log/nginx_access.log;
        error_log   /var/lib/gitea/log/nginx_error.log;
        rewrite     ^/git/(.*)$ /$1 break;
        proxy_pass  http://localhost:3000;
        proxy_read_timeout  90;
        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 $scheme;
    }

    include /var/www/example/www/nginx.conf;
    include snippets/wordpress.conf;
}

Gitea config
APP_NAME = Gitea
RUN_USER = gitea
RUN_MODE = prod

[server]
#PROTOCOL = https    #https complains about a cert. I want nginx to handle ssl.
DOMAIN           = example.com
ROOT_URL         = https://example.com/git/   # See, it's set
# STATIC_URL_PREFIX = /git/   # Did not help. I was only able to get static assets w/ nginx
LFS_JWT_SECRET   = xxxxx
SSH_DOMAIN       = example.com
HTTP_PORT        = 3000
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_START_SERVER = true
LFS_CONTENT_PATH = /var/lib/gitea/data/lfs
OFFLINE_MODE     = false

[database]
DB_TYPE  = mysql
HOST     = 127.0.0.1:3306
NAME     = xxxxx
USER     = xxxxx
PASSWD   = xxxxxx
LOG_SQL  = false
SCHEMA   =
SSL_MODE = disable
CHARSET  = utf8mb4
PATH     = /var/lib/gitea/data/gitea.db

[security]
INSTALL_LOCK       = true
SECRET_KEY         =
INTERNAL_TOKEN     = xxxxxx
PASSWORD_HASH_ALGO = xxxxx

[oauth2]
ENABLE = false

[U2F]
APP_ID =

[log]
MODE              = file
LEVEL             = info
# ROUTER = console
ENABLE_ACCESS_LOG = true
ACCESS            = file
ROOT_PATH         = /var/lib/gitea/log
ROUTER            = console

[service]
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = false
DISABLE_REGISTRATION              = true
ALLOW_ONLY_EXTERNAL_REGISTRATION  = false
ENABLE_CAPTCHA                    = false
REQUIRE_SIGNIN_VIEW               = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = false
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.example.com
DEFAULT_USER_VISIBILITY           = private
DEFAULT_ORG_VISIBILITY            = private
REQUIRE_SIGNIN_VIEW               = true
DISABLE_USERS_PAGE                = true

[repository]
ROOT = /var/lib/gitea/data/gitea-repositories

[mailer]
ENABLED = false

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[session]
PROVIDER = file

[ui]
DEFAULT_THEME = gitea
THEMES = auto,gitea,arc-green

Last 1000 lines of the gitea log.
gitea1000.txt

Gitea Version

1.16.8-1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.30.2-1

Operating System

Debian stable

How are you running Gitea?

Gitea 1.16.8-1 debian package from https://gitlab.com/packaging/gitea
No static assets included, so I built them after downloading the repo.
Running on a debian linux VPS w/ a sysvinit script.
Proxy via nginx 1.18.0-6.1.
Data stored in mariadb 10.5.15-0.

Database

MySQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions