Skip to content

unauthorized: reqpackageaccess when pushing to container registry #36910

Description

@gilgoolon

Description

I setup a fresh Gitea installation trying to push my docker image to the user docker regsitry.
I get the following error:

The push refers to repository [<domain><user><image_name>]
efafae78d70c: Preparing 
unauthorized: reqPackageAccess

And the logs show something like this (I copied this from another thread but its the same log):

2024/07/07 08:32:03 ...eb/routing/logger.go:102:func1() [I] router: completed POST /v2/dlmw/minecraft/blobs/uploads/ for 10.0.0.2:0, 401 Unauthorized in 1.1ms @ packages/api.go:42(packages.ContainerRoutes.func2.1.reqPackageAccess.4)
2024/07/07 08:32:03 ...eb/routing/logger.go:102:func1() [I] router: completed POST /v2/dlmw/minecraft/blobs/uploads/ for 10.0.0.2:0, 401 Unauthorized in 1.1ms @ packages/api.go:42(packages.ContainerRoutes.func2.1.reqPackageAccess.4)

I saw #31531, scanned for all related issues and disocrd messages, and it seems this was solved for everyone by using a PAT, or turned out to be a proxy issue.

I have tried the following:

  • using a PAT with all or some permissions (with packages read/write)
  • logging as a different account
  • logging as an admin account
  • enabling all sorts of settings in the gitea configuration
  • enabling all sorts of settings in the nginx configuration
  • reading the documentation
  • reinstalling 3 different gitea version
  • using MySQL instead of Sqlite
  • using docker-compose instead of snap

All of the above yielded the exact same error.
Its worth noting that everything else works flawlessly, I got up an action runner working etc...

When I disable my reverse proxy entirely (and modify the gitea configuration accordingly) and try to push directory to localhost docker refuses to cooporate since it requires https.

Here are my current configurations:
/var/snap/gitea/common/conf/app.ini

APP_NAME = ...
RUN_USER = root
WORK_PATH = /var/snap/gitea/common
RUN_MODE = prod

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = giteadb
USER = gitea
PASSWD = ...
SCHEMA = 
SSL_MODE = disable
PATH = /var/snap/gitea/common/data/gitea.db
LOG_SQL = false

[repository]
ROOT = /var/snap/gitea/common/data/gitea-repositories

[server]
SSH_DOMAIN = localhost
DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://domain.com/
APP_DATA_PATH = /var/snap/gitea/common/data
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_JWT_SECRET = m9CFrRAuU1LR4RCFsQRgP2BdE9kpnqRaJVB_Oxv28zU
OFFLINE_MODE = true

[lfs]
PATH = /var/snap/gitea/common/data/lfs

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply.localhost

[openid]
ENABLE_OPENID_SIGNIN = true
ENABLE_OPENID_SIGNUP = true

[cron.update_checker]
ENABLED = false

[session]
PROVIDER = file

[log]
MODE = console
LEVEL = info
ROOT_PATH = /var/snap/gitea/common/log

[repository.pull-request]
DEFAULT_MERGE_STYLE = merge

[repository.signing]
DEFAULT_TRUST_MODEL = committer

[security]
INSTALL_LOCK = true
INTERNAL_TOKEN = ...
PASSWORD_HASH_ALGO = pbkdf2

[oauth2]
JWT_SECRET = ...

I tried directlly curling the docker api directly (via the proxy), with an authorization header (-u :) every time, and it worked, that way I can upload a package.

This points to the nginx configuration hiding some header or something, but when I sniff it with wireshark it seems like all the headers are there (this is after a successful login request):

POST /v2/username/image/blobs/uploads/ HTTP/1.0
Host: domain.com
X-Real-IP: 127.0.0.1
X-Forwarded-For: 127.0.0.1
X-Forwarded-Proto: https
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NzM3NDAzNjMsIm5iZiI6MTc3MzY1Mzk2MywiVXNlcklEIjotMSwiU2NvcGUiOiIifQ.PCVoCvG1bTUtG-dD9LA47koYWBuNV5UPk11Oqlqm3qU
Connection: close
Content-Length: 0
User-Agent: docker/29.3.0 go/go1.25.7 git-commit/83bca51 kernel/6.17.0-19-generic os/linux arch/amd64 UpstreamClient(Docker-Client/29.3.0 \(linux\))
Accept-Encoding: gzip


HTTP/1.0 401 Unauthorized
Content-Type: text/plain; charset=utf-8
Www-Authenticate: Basic realm="Gitea Package API"
X-Content-Type-Options: nosniff
Date: Mon, 16 Mar 2026 09:39:23 GMT
Content-Length: 17

reqPackageAccess

here is my nginx configuration (tried multiple, but this is what I landed on):

server {
    listen 80;
    server_name domain.com;
    # Redirect all HTTP traffic to HTTPS
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/domain.crt;
    ssl_certificate_key /etc/nginx/ssl/domain.key;

    client_max_body_size 0; 
    chunked_transfer_encoding on;

    location / {
        proxy_pass http://localhost:3000; # Or your internal Gitea IP
        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;
        
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header Authorization $http_authorization;
        proxy_pass_header Authorization;
    }

    location /v2 {
        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;

        proxy_set_header Authorization $http_authorization;
        proxy_pass_header Authorization;

        proxy_pass http://localhost:3000;
        proxy_read_timeout 900;
    }
}

I may have forgot to mention a few things I tried, but this is getting too long so just ask if you need more info..

Gitea Version

1.25.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Ubuntu 24.04

How are you running Gitea?

systemd (installed via snap)

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detail

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions