Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

dns - 球童多域反向代理(Caddy multi-domain reverse proxy)

I'm new to Caddy server but their website looked promising.

(我是Caddy服务器的新手,但他们的网站看起来很有希望。)

I want to use it as a reverse proxy for the websites that are hosted on other servers.

(我想将其用作其他服务器上托管的网站的反向代理。)

So, I have 2 websites;

(因此,我有2个网站;)

a Wiki and a photo gallery, that needs to be hosted outside of my local network.

(一个Wiki和一个图片库,它们需要托管在我的本地网络之外。)

Caddyfile (球童档案)

My Caddyfile is pretty straight forward:

(我的Caddyfile非常简单:)

coppery.<my domain name> {
  proxy / http://192.168.1.66:80 {
    transparent
  }
}

wiki.<my domain name> {
  proxy / http://192.168.1.88:8080 {
    transparent
  }
}

When I first started caddy I saw some HTTPS stuff with lets encrypt but that was succesful so now when I start it I get this output:

(当我第一次启动caddy我看到了一些带有let加密的HTTPS东西,但是那是成功的,所以现在当我启动它时,我得到以下输出:)

root@caddy:~# caddy 
Activating privacy features... done.

Serving HTTPS on port 443 
https://coppery.<my domain name>
https://wiki.<my domain name>


Serving HTTP on port 80 
http://coppery.<my domain name>
http://wiki.<my domain name>

WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.

I think for now I can dismiss the warning, I might solve that in the future but this is not a production environment anyway.

(我认为目前我可以消除该警告,以后可能会解决该问题,但是无论如何这不是生产环境。)

Portforwarding and DNS (端口转发和DNS)

I configured the domain names to resolve to my IP address (this already worked) and when I ping the domain names, they resolve the IP address correctly.

(我将域名配置为解析为我的IP地址(这已经起作用),当我ping域名时,它们可以正确解析IP地址。)

When I access the IP-addresses directly from my local network it works, I get the websites I expect.

(当我直接从本地网络访问IP地址时,它可以正常工作,我得到了我期望的网站。)

So I added some configuration on my router and port forwarded port 80 and 443 to the local IP address of the machine hosting the Caddy server.

(因此,我在路由器上添加了一些配置,并将端口转发的端口80和443转发到了托管Caddy服务器的计算机的本地IP地址。)

Now when I try to access coppery.<my domain name> on either HTTP or HTTPS it's not showing anything.

(现在,当我尝试通过HTTP或HTTPS访问coppery.<my domain name> ,它什么都没有显示。)

So my only guess is that there is something wrong with the Caddyfile configuration but it's a realy simple case and all I've done is using the examples I found online.

(因此,我唯一的猜测是Caddyfile配置有问题,但这是一个非常简单的案例,我所做的只是使用我在网上找到的示例。)

Which don't seem to work.

(哪个似乎不起作用。)

So the question is: What am I missing to make this work as intended?

(所以问题是:要使这项工作按预期进行,我缺少什么?)

  ask by Ravenix translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem was the DNS.

(问题是DNS。)

Once I configured the domain names in my local host file it worked.

(在我的本地主机文件中配置域名后,它就可以工作了。)

So the configuration in my question is all correct.

(所以我的问题中的配置都是正确的。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...