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

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

	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里有以下相关设置:

[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

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

我想问问是我有哪里配置不对吗,希望有大佬能帮帮我。 :smiling_face_with_tear:

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/

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.

Is there a solution to meet my need? please.

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

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.

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 to your LAN IP when you are at your home

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.