# “版本发布”下，自己上传的文件url错误

**URL:** <https://forum.gitea.com/t/url/8030>\
**Category:** 中文求助(Chinese Only)\
**Created:** [October 31, 2023, 1:12pm UTC](https://forum.gitea.com/t/url/8030 "2023-10-31T13:12:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepfish5](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sheepfish5](https://forum.gitea.com/u/sheepfish5)\
**Post date:** [October 31, 2023, 1:12pm UTC](https://forum.gitea.com/t/url/8030/1 "2023-10-31T13:12:28Z")

</div>

gitea版本1.20.5，使用docker部署，使用nginx-1.18反向代理代理设置如下：

```nginx
	server {
 		listen 80;
 		server_name exp1.com exp2.com; # 需要多个域名访问gitea

 		location / {
  			proxy_pass http://localhost:3000;
			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;
		}
 	}

```

在`app.ini`里有以下相关设置：

```auto
[server]
APP_DATA_PATH = /data/gitea
DOMAIN = 192.168.1.103 # 运行gitea机器的ip
HTTP_PORT = 3000
DISABLE_SSH = false
OFFLINE_MODE = false
PROTOCOL = http
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s/

```

然后不管用哪个域名访问gitea，在“版本发布”下，自己上传的文件的链接的域名都是`192.168.1.103`：

 ![gitea帖子3](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/2X/6/6dd223c5690abae5d6e371044d899bfb64f09613.png)

如果有其它需要的日志或配置，我可以贴出来。如果是文档某些地方我瞎了没看到，我非常抱歉。

我想问问是我有哪里配置不对吗，希望有大佬能帮帮我。 🥲

---

<div class="post-metadata">

**Author:** ![dangjinghao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dangjinghao/32/4167_2.png) [@dangjinghao](https://forum.gitea.com/u/dangjinghao)\
**Post date:** [November 4, 2023, 3:47pm UTC](https://forum.gitea.com/t/url/8030/2 "2023-11-04T15:47:50Z")

</div>

The attachment root URL is depends on the `ROOT_URL` config.  
Modify your ROOT\_PATH (and DOMAIN)to what you want instead of `%(PROTOCOL)s://%(DOMAIN)s/`

---

<div class="post-metadata">

**Author:** ![sheepfish5](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sheepfish5](https://forum.gitea.com/u/sheepfish5)\
**Post date:** [November 6, 2023, 8:13am UTC](https://forum.gitea.com/t/url/8030/3 "2023-11-06T08:13:24Z")

</div>

Thank you for reply!  
But for some reason, I need to access my gitea through two hostname(`exp1.com` and `exp2.com`, for example). I did as you said to set `ROOT_URL=http://exp1.com/` and `DOMAIN=exp1.com`. It does be normal when I access my gitea through `http://exp1.com`, but when I use `http://exp2.com`, this attachment’s hostname is still `exp1.com`.

![](https://picdl.sunbangyan.cn/2023/11/06/0bc06d11110e2b16e226d49c1316290c.png)

Is there a solution to meet my need? please.

---

<div class="post-metadata">

**Author:** ![dangjinghao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dangjinghao/32/4167_2.png) [@dangjinghao](https://forum.gitea.com/u/dangjinghao)\
**Post date:** [November 7, 2023, 3:37pm UTC](https://forum.gitea.com/t/url/8030/4 "2023-11-07T15:37:47Z")

</div>

Same situation, so my solution is to ensure that both of the domains can be resolved to my gitea server.

---

<div class="post-metadata">

**Author:** ![sheepfish5](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sheepfish5](https://forum.gitea.com/u/sheepfish5)\
**Post date:** [November 8, 2023, 3:08pm UTC](https://forum.gitea.com/t/url/8030/5 "2023-11-08T15:08:53Z")

</div>

Thank you. But my situation is a little complex.

In my situation, `exp1.com` is used in my local area network while `exp2.com` is used on the Internet through intranet tunneling provided by `hsk.oray.com`.

If I set `ROOT_URL = http://exp1.com/`, then I can’t access my attachment in one go. I need to copy the attachment url manually, paste in my Edge browser and change `exp1.com` to `exp2.com`, which is quite troublesome.

I don’t want to set `ROOT_URL = https://exp2.com`, because the bandwidth is only 1Mb and the data traffic is only 5GB per month. Furthermore, I don’t want to download in such a poor speed in my LAN.

I think your solution may not meet my need or there may be other issues with my understanding.

---

<div class="post-metadata">

**Author:** ![dangjinghao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dangjinghao/32/4167_2.png) [@dangjinghao](https://forum.gitea.com/u/dangjinghao)\
**Post date:** [November 9, 2023, 2:01am UTC](https://forum.gitea.com/t/url/8030/6 "2023-11-09T02:01:00Z")

</div>

Ok, It sounds like you have a LAN server. You can build a custom DNS server (like coreDNS), and modify the nameserver configuration of your router or computer.  
You can custom DNS resolutin, solving [ex1.com](http://ex1.com) to your LAN IP when you are at your home

---

<div class="post-metadata">

**Author:** ![sheepfish5](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sheepfish5](https://forum.gitea.com/u/sheepfish5)\
**Post date:** [November 11, 2023, 12:21pm UTC](https://forum.gitea.com/t/url/8030/7 "2023-11-11T12:21:11Z")

</div>

Thank you!  
Yes, it’s a good solution. I’ve also thought about this method. But I still expect gitea could be self-adaption. When I access my gitea instance through `exp1.com`, I expect the hostname of the attachment’s url should be `exp1.com`, and when I use `exp2.com`, it should be `exp2.com` just like the other things in gitea.

I wondered whether this can be achieved by change some configurations. I’ve searched the docs of gitea and found such a statement `ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/`. But this doesn’t work on the hostname of the attachment’url as I expect.

Why doesn’t this work on the hostname of the attachment’url as I expect? Is it for other reasons when designed or just a bug or my configuration fault? If my expect can’t be achieved, I’ll try set up a local DNS server as you told.
