全球主机交流论坛

标题: caddy 配置文件问题,怎么就不对呢? [打印本页]

作者: Lwstress    时间: 2019-9-27 13:59
标题: caddy 配置文件问题,怎么就不对呢?
caddy 配置文件问题,怎么就不对呢?

http://beggar.tk:80{
        redir https://www.beggar.tk:443{url}
        }
http://www.beggar.tk:80{
        redir https://www.beggar.tk:443{url}
        }
https://www.beggar.tk:443 {
        gzip
        tls [email protected]
        root /www
        proxy /2cb30ddb localhost:25930 {
                websocket
                header_upstream -Origin
        }
        fastcgi / /run/php/php7.0-fpm.sock php
}

测试不行

http://www.beggar.tk:80, http://beggar.tk:80{
        redir https://www.beggar.tk:443{url}
        }
https://www.beggar.tk:443 {
        gzip
        tls [email protected]
        root /www
        proxy /2cb30ddb localhost:25930 {
                websocket
                header_upstream -Origin
        }
        fastcgi / /run/php/php7.0-fpm.sock php
}

也不行

到底该怎么写
就是@和www都转移到https

作者: ben1225    时间: 2019-9-27 14:02
caddy -conf=/path/to/Caddyfile
看哪里出错
作者: Lwstress    时间: 2019-9-27 14:06
ben1225 发表于 2019-9-27 14:02
caddy -conf=/path/to/Caddyfile
看哪里出错

2019/09/27 02:05:40 error inspecting server blocks: parse http://beggar.tk:80{: invalid port ":80{" after host

作者: aming    时间: 2019-9-27 14:06
根本没搞懂你是想怎样的

只是想加证书,直接域名就行,会自动跳转,也没有redir的

beggar.tk  {

}

你是不想要证书的


beggar.tk:80  {

}

想要支持php的,首先确认你存在 /run/php/php7.0-fpm.sock php 这个路径和文件,而不是照搬

     fastcgi / /run/php/php7.0-fpm.sock php {
         ext .php
         split .php
         index index.php
     }

也可以用  fastcgi / 127.0.0.1:9000 php
作者: Lwstress    时间: 2019-9-27 14:07
Lwstress 发表于 2019-9-27 14:06
2019/09/27 02:05:40 error inspecting server blocks: parse http://beggar.tk:80{: invalid port ":80{ ...

看起来...  是我括号写错了

写好了提醒重定向次数太多;
作者: loveqianool    时间: 2019-9-27 14:08
  1. https://www.beggar.tk, http://www.beggar.tk {
  2. redir  301 {
  3. if {host} is beggar.tk
  4. / https://www.{host}{uri}
  5. }
  6. gzip
  7. tls [email protected]
  8. root /www
  9. proxy /2cb30ddb localhost:25930 {
  10. websocket
  11. header_upstream -Origin
  12. }
  13. fastcgi / /run/php/php7.0-fpm.sock php
  14. on startup php-fpm7
  15. header / {
  16. Strict-Transport-Security "max-age=31536000;includeSubdomains;preload"
  17. }
  18. }
复制代码

作者: 秘密    时间: 2019-9-27 14:12
提示: 作者被禁止或删除 内容自动屏蔽
作者: Lwstress    时间: 2019-9-27 14:13
aming 发表于 2019-9-27 14:06
根本没搞懂你是想怎样的

只是想加证书,直接域名就行,会自动跳转,也没有redir的

想法是,
http://beggar.tk 和http://www.beggar.tk
都跳转到https://beggar.tk

支持PHP的文件是存在的.
作者: 秘密    时间: 2019-9-27 14:15
提示: 作者被禁止或删除 内容自动屏蔽
作者: 寒冰飞雪    时间: 2019-9-27 14:15
用宝塔的nginx
作者: aming    时间: 2019-9-27 14:16
Lwstress 发表于 2019-9-27 14:13
想法是,
http://beggar.tk 和http://www.beggar.tk
都跳转到https://beggar.tk

caddy 不是 nginx
不需要跳转,能自动处理
只需要

xxxx.com  {

}

作者: Lwstress    时间: 2019-9-27 14:16
秘密 发表于 2019-9-27 14:15
重定向太多,我才你用了cf,要到cf里改ssl模式

是滴,,, 对哈 还有重定向太多这个 可以通过CF的设置面板修改!
作者: Lwstress    时间: 2019-9-27 14:19
loveqianool 发表于 2019-9-27 14:08

感谢大佬提供帮助!
作者: loveqianool    时间: 2019-9-27 14:29
Lwstress 发表于 2019-9-27 14:19
感谢大佬提供帮助!

能用吗?套 wss 我从来没成功过。
作者: Lwstress    时间: 2019-9-27 14:47
loveqianool 发表于 2019-9-27 14:29
能用吗?套 wss 我从来没成功过。

我还是我原来的写的方式

然后直接设置下CF的SSL就可以了.

上次我就括号写错了
作者: jqk444    时间: 2019-9-27 15:16
  1. www.beggar.tk {
  2.         gzip
  3.         root /www
  4.         proxy /2cb30ddb localhost:25930 {
  5.                 websocket
  6.                 header_upstream -Origin
  7.         }
  8.         fastcgi / /run/php/php7.0-fpm.sock php
  9. }
复制代码

作者: jqk444    时间: 2019-9-27 15:19
  1. www.beggar.tk {
  2.         gzip
  3.         root /www
  4.         proxy /2cb30ddb localhost:25930 {
  5.                 websocket
  6.                 header_upstream -Origin
  7.         }
  8.         fastcgi / /run/php/php7.0-fpm.sock php
  9. }
复制代码


作者: aming    时间: 2019-9-27 15:36
拜托,都用人家的产品,好歹也去官方瞧一下,caddy 卖点就是全自动 HTTPS ,默认就是 HTTPS ,首页大写的两行吹爆自家特点:

EVERY site on HTTPS
Caddy is the HTTP/2 web server with automatic HTTPS.


支持HTTPS又不是caddy特有,哪一个web server都支持,但原生自动支持目前就 caddy ,不然caddy谁用,怎么抢市场的
作者: longhtml    时间: 2019-9-27 16:17
  1. test.com
  2. {
  3.   tls [email protected]
  4.   tls {
  5.     dns cloudflare
  6.   }  
  7.   log / /etc/caddy/test.com_access.log "{combined}" {
  8.     rotate_size 100 # Rotate a log when it reaches 100 MB
  9.     rotate_age  14  # Keep rotated log files for 14 days
  10.     rotate_keep 10  # Keep at most 10 rotated log files
  11.     rotate_compress # Compress rotated log files in gzip format
  12.   }
  13.   errors  /etc/caddy/test.com_error.log {
  14.     404 404.html # Not Found
  15.     rotate_size 100 # Rotate a log when it reaches 100 MB
  16.     rotate_age  14  # Keep rotated log files for 14 days
  17.     rotate_keep 10  # Keep at most 10 rotated log files
  18.     rotate_compress # Compress rotated log files in gzip format  
  19.   }  
  20.   root /etc/caddy/www
  21. }
  22. www.test.com
  23. {
  24.   redir https://test.com{uri}
  25. }
复制代码

作者: hmy111    时间: 2019-9-27 16:20
Lwstress 发表于 2019-9-27 14:16
是滴,,, 对哈 还有重定向太多这个 可以通过CF的设置面板修改!

请问cf面板要怎么修改呢?我也是重定向过多
作者: Lwstress    时间: 2019-9-27 17:03
hmy111 发表于 2019-9-27 16:20
请问cf面板要怎么修改呢?我也是重定向过多

域名
作者: hmy111    时间: 2019-9-27 18:06
Lwstress 发表于 2019-9-27 17:03
域名

域名?不是修改SSL的设置?
楼主我没明白啊 说详细点
作者: Lwstress    时间: 2019-9-27 18:32
hmy111 发表于 2019-9-27 18:06
域名?不是修改SSL的设置?
楼主我没明白啊 说详细点

就是你要设置的那个域名啊 然后进去了设置SSL就行了 我上面不是说了么
作者: hmy111    时间: 2019-9-27 21:46
Lwstress 发表于 2019-9-27 18:32
就是你要设置的那个域名啊 然后进去了设置SSL就行了 我上面不是说了么

SSL设置成啥?full吗?
作者: 秘密    时间: 2019-9-27 21:47
提示: 作者被禁止或删除 内容自动屏蔽
作者: hmy111    时间: 2019-9-27 22:02
秘密 发表于 2019-9-27 21:47

非常感谢~




欢迎光临 全球主机交流论坛 (https://52.ht/) Powered by Discuz! X3.4