You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用curl向Nexus 2.14.11-01上传文件?返回403 Forbidden

Troubleshooting 403 Forbidden When Uploading to Nexus 2.14.11-01 Snapshots Repository

Let’s break down why you’re hitting that 403 error with your curl upload—even though you followed the official docs—and walk through actionable fixes for each likely cause:

1. Verify User Deployment Permissions

Nexus 2.x relies on strict role-based access control for repository deployments. Your user account must have the repository-snapshots-deploy permission to upload files to the snapshots repo. Here’s how to check:

  • Log into your Nexus web UI
  • Navigate to Security > Users and locate your username
  • Click the Roles tab for that user
  • Confirm one of their assigned roles includes the repository-snapshots-deploy permission (you can audit role permissions under Security > Roles)

If the permission is missing, either:

  • Add an existing role with deploy access to your user, or
  • Create a custom role that includes repository-snapshots-deploy and assign it to your user

2. Check the Repository’s Deployment Policy

Even with the right permissions, if the snapshots repo itself blocks deployments, you’ll get a 403. To validate:

  • Go to Repositories in the Nexus UI
  • Select your snapshots repository and click the Configuration tab
  • Look for the Deployment Policy setting: it must be set to Allow Redeploy (snapshot repos require this to allow overwriting existing artifacts)

If it’s set to Read-Only or Disable Redeploy, switch it to Allow Redeploy and save the configuration.

3. Fix Your Upload URL Path

Looking at your curl command, the path structure doesn’t match the standard Maven repository layout Nexus expects. The correct format is:
/repositories/snapshots/[groupId-with-dashes-replaced-by-slashes]/[artifactId]/[version]/[artifact-file]

Your current path has com.example.snapshot/com/example/myscripts/... which is incorrect. If your group ID is com.example.snapshot, artifact ID is myscripts, and version is 1.2.3-SNAPSHOT, the corrected URL should be:

https://example.com/nexus/content/repositories/snapshots/com/example/snapshot/myscripts/1.2.3-SNAPSHOT/file-1.2.3-SNAPSHOT.ext

A malformed path can trigger a 403 even if your permissions are valid, as Nexus can’t map it to a valid repository location.

4. Validate Basic Authentication

While your curl output shows it’s using Basic auth, double-check these details:

  • Confirm your username and password work by logging into the Nexus UI with the same credentials
  • If your password contains special characters (like @, &, !), use curl’s interactive auth mode to avoid encoding mistakes:
    curl -v -u username --upload-file file.ext https://example.com/nexus/content/repositories/snapshots/com/example/snapshot/myscripts/1.2.3-SNAPSHOT/file-1.2.3-SNAPSHOT.ext
    
    Curl will prompt you for your password, eliminating encoding-related errors.

5. Check Nexus Logs for Exact Error Details

If none of the above fixes work, dive into Nexus’s server logs for the root cause. For Nexus 2.14.11-01, logs are located at:

sonatype-work/nexus/logs/nexus.log

Look for entries timestamped around when you ran your curl command—they’ll explicitly state whether the error is permission-related, path-related, or something else entirely.

Quick Auth Validation Test

First, confirm your authentication works by running a simple GET request to the snapshots repo root:

curl -v -u username:password https://example.com/nexus/content/repositories/snapshots/

If this returns a 200 OK with repository content, your auth is valid, and the issue is likely tied to deployment permissions or path structure.


内容的提问来源于stack exchange,提问作者JJD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:03:20