V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
bigxu
V2EX  ›  问与答

在开发环境中, caddyserver 中,为多个站点写一个配置文件

  •  
  •   bigxu · Jan 18, 2018 · 4623 views
    This topic created in 3034 days ago, the information mentioned may be changed or developed.

    想法是这样的:

    *.localhost:80 {
        root /var/www/{hostonly}/public
        fastcgi / php-fpm:9000 php {
            index index.php
        }
        rewrite {
            to {path} {path}/ /index.php?{query}
        }
        gzip
        browse
        log stdout
        errors stdout
        log / stdout {hostonly}
    } 
    

    但是终端输出:
    caddy_1 | 18/Jan/2018:09:43:51 +0000 [ERROR 0 /index.php] Primary script unknown
    caddy_1 | 172.20.0.1 - - [18/Jan/2018:09:43:51 +0000] "GET /index.php HTTP/1.1" 404 40
    caddy_1 | xxx.localhost

    当然 /var/www/xxx.localhost/pulbic/index.php 其实是存在的。

    5 replies    2018-01-18 21:50:53 +08:00
    bigxu
        1
    bigxu  
    OP
       Jan 18, 2018
    caddyserver
    bigxu
        2
    bigxu  
    OP
       Jan 18, 2018
    KgM4gLtF0shViDH3
        3
    KgM4gLtF0shViDH3  
       Jan 18, 2018 via Android
    go 写的那个 server ?
    bigxu
        4
    bigxu  
    OP
       Jan 18, 2018
    这样调试多个项目,就不用为每个项目更改 Caddyfile,并且重启了。
    ```
    *.localhost:80 {
    root /var/www/
    fastcgi / php-fpm:9000 php {
    index index.php
    }
    rewrite {
    to /{hostonly}/public/{path} /{hostonly}/public/{path}/ /{hostonly}/public/index.php?{query}
    }
    gzip
    browse
    log stdout
    errors stdout
    log /var/log/caddy/{hostonly}.access.log
    errors /var/log/caddy/{hostonly}.error.log
    }

    ```
    bigxu
        5
    bigxu  
    OP
       Jan 18, 2018
    @bestkayle 是啊。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5672 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 07:54 · PVG 15:54 · LAX 00:54 · JFK 03:54
    ♥ Do have faith in what you're doing.