caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.1k stars 4.03k forks source link

It is hoped that http/3 support can be enabled when "listen" uses Unix socket paths. #3946

Closed lxhao61 closed 3 years ago

lxhao61 commented 3 years ago

It is found that listen uses the Unix socket path. Once http/3 is enabled, it cannot be started. After http/3 is closed, it starts normally.

francislavoie commented 3 years ago

Thanks for opening an issue! We'll look into this.

It's not immediately clear to us what is going on, so we'll need your help to understand it better.

Ideally, we need to be able to reproduce the bug in the most minimal way possible. This allows us to write regression tests to verify the fix is working. If we can't reproduce it, then you'll have to test our changes for us until it's fixed -- and then we can't add test cases, either.

I've attached a template below that will help make this easier and faster! It will ask for some information you've already provided; that's OK, just fill it out the best you can. :+1:

I've also included some helpful tips below the template. Feel free to let me know if you have any questions!

Thank you again for your report, we look forward to resolving it!

Template

## 1. Environment

### 1a. Operating system and version

```
paste here
```

### 1b. Caddy version (run `caddy version` or paste commit SHA)

```
paste here
```

### 1c. Go version (if building Caddy from source; run `go version`)

```
paste here
```

## 2. Description

### 2a. What happens (briefly explain what is wrong)

### 2b. Why it's a bug (if it's not obvious)

### 2c. Log output

```
paste terminal output or logs here
```

### 2d. Workaround(s)

### 2e. Relevant links

## 3. Tutorial (minimal steps to reproduce the bug)

Helpful tips

  1. Environment: Please fill out your OS and Caddy versions, even if you don't think they are relevant. (They are always relevant.) If you built Caddy from source, provide the commit SHA and specify your exact Go version.

  2. Description: Describe at a high level what the bug is. What happens? Why is it a bug? Not all bugs are obvious, so convince readers that it's actually a bug.

    • 2c) Log output: Paste terminal output and/or complete logs in a code block. DO NOT REDACT INFORMATION except for credentials.
    • 2d) Workaround: What are you doing to work around the problem in the meantime? This can help others who encounter the same problem, until we implement a fix.
    • 2e) Relevant links: Please link to any related issues, pull requests, docs, and/or discussion. This can add crucial context to your report.
  3. Tutorial: What are the minimum required specific steps someone needs to take in order to experience the same bug? Your goal here is to make sure that anyone else can have the same experience with the bug as you do. You are writing a tutorial, so make sure to carry it out yourself before posting it. Please:

    • Start with an empty config. Add only the lines/parameters that are absolutely required to reproduce the bug.
    • Do not run Caddy inside containers.
    • Run Caddy manually in your terminal; do not use systemd or other init systems.
    • If making HTTP requests, avoid web browsers. Use a simpler HTTP client instead, like curl.
    • Do not redact any information from your config (except credentials). Domain names are public knowledge and often necessary for quick resolution of an issue!
    • Note that ignoring this advice may result in delays, or even in your issue being closed. 😞 Only actionable issues are kept open, and if there is not enough information or clarity to reproduce the bug, then the report is not actionable.

Example of a tutorial:

Create a config file: ``` { ... } ``` Open terminal and run Caddy: ``` $ caddy ... ``` Make an HTTP request: ``` $ curl ... ``` Notice that the result is ___ but it should be ___.
lxhao61 commented 3 years ago

Configuration Template: { "admin": { "disabled": true }, "apps": { "http": { "servers": { "srv0": { "listen": ["unix//dev/shm/web.sock"], "routes": [{ "handle": [{ "handler": "file_server", "root": "/var/www/html" }], "terminal": true }], "tls_connection_policies": [{ "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], "alpn": ["h2","http/1.1"], "default_sni": "*.xx.yy" }], "experimental_http3": false } } }, "tls": { "certificates": { "load_files": [{ "certificate": "/etc/ssl/tls/xx.yy.crt", "key": "/etc/ssl/tls/xx.yy.key" }] } } } }

If you configure http/3 to enable (change false to true), you cannot start it.

francislavoie commented 3 years ago

Please fill out the template I gave. What error are you seeing? Please use ``` to use code formatting, otherwise your JSON config is very hard to follow.

lxhao61 commented 3 years ago

1. Environment

1a. Operating system and version

Debian 10.2

1b. Caddy version (run caddy version or paste commit SHA)

v2.2.1

1c. Go version (if building Caddy from source; run go version)

paste here

2. Description

2a. What happens (briefly explain what is wrong)

Configuration Template: { "admin": { "disabled": true }, "apps": { "http": { "servers": { "srv0": { "listen": ["unix//dev/shm/web.sock"], "routes": [{ "handle": [{ "handler": "file_server", "root": "/var/www/html" }], "terminal": true }], "tls_connection_policies": [{ "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], "alpn": ["h2","http/1.1"], "default_sni": "*.xx.yy" }], "experimental_http3": false } } }, "tls": { "certificates": { "load_files": [{ "certificate": "/etc/ssl/tls/xx.yy.crt", "key": "/etc/ssl/tls/xx.yy.key" }] } } } }

If you configure http/3 to enable (change false to true), you cannot start it.

2b. Why it's a bug (if it's not obvious)

If you configure http/3 to enable (change false to true), you cannot start it.

root@VM-4-15-debian:~# systemctl status caddy ● caddy.service - Caddy Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2020-12-31 03:14:59 HKT; 32s ago Docs: https://caddyserver.com/docs/ Process: 11348 ExecStart=/usr/local/bin/caddy/caddy run --environ --config /usr/local/etc/caddy/caddy.json (code=exited, status=1/FAILURE) Main PID: 11348 (code=exited, status=1/FAILURE)

Dec 31 03:14:59 VM-4-15-debian caddy[11348]: USER=root Dec 31 03:14:59 VM-4-15-debian caddy[11348]: SHELL=/bin/sh Dec 31 03:14:59 VM-4-15-debian caddy[11348]: INVOCATION_ID=07b9d55b8f1248da9c28750aa6bd382f Dec 31 03:14:59 VM-4-15-debian caddy[11348]: JOURNAL_STREAM=9:93789 Dec 31 03:14:59 VM-4-15-debian caddy[11348]: {"level":"info","ts":1609355699.6450908,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json Dec 31 03:14:59 VM-4-15-debian caddy[11348]: {"level":"warn","ts":1609355699.6456673,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 03:14:59 VM-4-15-debian caddy[11348]: {"level":"info","ts":1609355699.6457791,"msg":"redirected default logger","from":"stderr","to":"/var/log/caddy/access.log"} Dec 31 03:14:59 VM-4-15-debian caddy[11348]: run: loading initial config: loading new config: http app module: start: getting HTTP/3 UDP listener: listen udp: address / Dec 31 03:14:59 VM-4-15-debian systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE Dec 31 03:14:59 VM-4-15-debian systemd[1]: caddy.service: Failed with result 'exit-code'.

2c. Log output

paste terminal output or logs here

2d. Workaround(s)

unix//dev/shm/web.sock was changed to 127.0.0.1:7443, and there was no problem starting http/3.

2e. Relevant links

3. Tutorial (minimal steps to reproduce the bug)

mholt commented 3 years ago

Thanks, but your logs are truncated. You can't copy and paste systemctl status output because the command truncates the logs. Please post the full logs. (journalctl -u caddy --no-pager)

lxhao61 commented 3 years ago

root@VM-4-15-debian:~# journalctl -u caddy --no-pager -- Logs begin at Thu 2020-12-31 03:39:48 HKT, end at Thu 2020-12-31 04:12:42 HKT. -- Dec 31 03:40:21 VM-4-15-debian systemd[1]: Started Caddy. Dec 31 03:40:21 VM-4-15-debian caddy[496]: {"level":"warn","ts":1609357221.4902544,"msg":"unable to determine directory for user configuration; falling back to current directory","error":"neither $XDG_CONFIG_HOME nor $HOME are defined"} Dec 31 03:40:21 VM-4-15-debian caddy[496]: caddy.HomeDir=. Dec 31 03:40:21 VM-4-15-debian caddy[496]: caddy.AppDataDir=./caddy Dec 31 03:40:21 VM-4-15-debian caddy[496]: {"level":"warn","ts":1609357221.6785388,"msg":"unable to determine directory for user configuration; falling back to current directory","error":"neither $XDG_CONFIG_HOME nor $HOME are defined"} Dec 31 03:40:21 VM-4-15-debian caddy[496]: caddy.AppConfigDir=./caddy Dec 31 03:40:21 VM-4-15-debian caddy[496]: caddy.ConfigAutosavePath=caddy/autosave.json Dec 31 03:40:21 VM-4-15-debian caddy[496]: caddy.Version=v2.2.1 Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.GOOS=linux Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.GOARCH=amd64 Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.Compiler=gc Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.NumCPU=1 Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.GOMAXPROCS=1 Dec 31 03:40:21 VM-4-15-debian caddy[496]: runtime.Version=go1.15.2 Dec 31 03:40:21 VM-4-15-debian caddy[496]: os.Getwd=/ Dec 31 03:40:21 VM-4-15-debian caddy[496]: LANG=en_US.UTF-8 Dec 31 03:40:21 VM-4-15-debian caddy[496]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Dec 31 03:40:21 VM-4-15-debian caddy[496]: LOGNAME=nobody Dec 31 03:40:21 VM-4-15-debian caddy[496]: USER=nobody Dec 31 03:40:21 VM-4-15-debian caddy[496]: INVOCATION_ID=4a3de112880e42c38f7be65fe71aab6b Dec 31 03:40:21 VM-4-15-debian caddy[496]: JOURNAL_STREAM=9:14002 Dec 31 03:40:21 VM-4-15-debian caddy[496]: {"level":"info","ts":1609357221.681023,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json","config_adapter":""} Dec 31 03:40:21 VM-4-15-debian caddy[496]: {"level":"warn","ts":1609357221.6816554,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 03:40:21 VM-4-15-debian caddy[496]: {"level":"info","ts":1609357221.6817777,"msg":"redirected default logger","from":"stderr","to":"/var/log/caddy/access.log"} Dec 31 04:00:33 VM-4-15-debian systemd[1]: Stopping Caddy... Dec 31 04:00:35 VM-4-15-debian caddy[496]: 2020/12/31 04:00:35 [DEBUG] Fake-closing underlying packet conn Dec 31 04:00:35 VM-4-15-debian systemd[1]: caddy.service: Succeeded. Dec 31 04:00:35 VM-4-15-debian systemd[1]: Stopped Caddy. Dec 31 04:01:40 VM-4-15-debian systemd[1]: Started Caddy. Dec 31 04:01:41 VM-4-15-debian caddy[4079]: {"level":"warn","ts":1609358501.0110846,"msg":"unable to determine directory for user configuration; falling back to current directory","error":"neither $XDG_CONFIG_HOME nor $HOME are defined"} Dec 31 04:01:41 VM-4-15-debian caddy[4079]: caddy.HomeDir=. Dec 31 04:01:41 VM-4-15-debian caddy[4079]: caddy.AppDataDir=./caddy Dec 31 04:01:41 VM-4-15-debian caddy[4079]: {"level":"warn","ts":1609358501.0450513,"msg":"unable to determine directory for user configuration; falling back to current directory","error":"neither $XDG_CONFIG_HOME nor $HOME are defined"} Dec 31 04:01:41 VM-4-15-debian caddy[4079]: caddy.AppConfigDir=./caddy Dec 31 04:01:41 VM-4-15-debian caddy[4079]: caddy.ConfigAutosavePath=caddy/autosave.json Dec 31 04:01:41 VM-4-15-debian caddy[4079]: caddy.Version=v2.2.1 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.GOOS=linux Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.GOARCH=amd64 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.Compiler=gc Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.NumCPU=1 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.GOMAXPROCS=1 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: runtime.Version=go1.15.2 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: os.Getwd=/ Dec 31 04:01:41 VM-4-15-debian caddy[4079]: LANG=en_US.UTF-8 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Dec 31 04:01:41 VM-4-15-debian caddy[4079]: LOGNAME=nobody Dec 31 04:01:41 VM-4-15-debian caddy[4079]: USER=nobody Dec 31 04:01:41 VM-4-15-debian caddy[4079]: INVOCATION_ID=9fb081c24fd4421ca0064b3f0b54f8f2 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: JOURNAL_STREAM=9:42426 Dec 31 04:01:41 VM-4-15-debian caddy[4079]: {"level":"info","ts":1609358501.047702,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json","config_adapter":""} Dec 31 04:01:41 VM-4-15-debian caddy[4079]: {"level":"warn","ts":1609358501.0483978,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 04:01:41 VM-4-15-debian caddy[4079]: {"level":"info","ts":1609358501.0484989,"msg":"redirected default logger","from":"stderr","to":"/var/log/caddy/access.log"} Dec 31 04:01:41 VM-4-15-debian caddy[4079]: run: loading initial config: loading new config: http app module: start: getting HTTP/3 UDP listener: listen udp: address /dev/shm/web.sock: missing port in address Dec 31 04:01:41 VM-4-15-debian systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE Dec 31 04:01:41 VM-4-15-debian systemd[1]: caddy.service: Failed with result 'exit-code'. Dec 31 04:07:34 VM-4-15-debian systemd[1]: Started Caddy. Dec 31 04:07:34 VM-4-15-debian caddy[5159]: caddy.HomeDir=/root Dec 31 04:07:34 VM-4-15-debian caddy[5159]: caddy.AppDataDir=/root/.local/share/caddy Dec 31 04:07:34 VM-4-15-debian caddy[5159]: caddy.AppConfigDir=/root/.config/caddy Dec 31 04:07:34 VM-4-15-debian caddy[5159]: caddy.ConfigAutosavePath=/root/.config/caddy/autosave.json Dec 31 04:07:34 VM-4-15-debian caddy[5159]: caddy.Version=v2.2.1 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.GOOS=linux Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.GOARCH=amd64 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.Compiler=gc Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.NumCPU=1 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.GOMAXPROCS=1 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: runtime.Version=go1.15.2 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: os.Getwd=/ Dec 31 04:07:34 VM-4-15-debian caddy[5159]: LANG=en_US.UTF-8 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Dec 31 04:07:34 VM-4-15-debian caddy[5159]: HOME=/root Dec 31 04:07:34 VM-4-15-debian caddy[5159]: LOGNAME=root Dec 31 04:07:34 VM-4-15-debian caddy[5159]: USER=root Dec 31 04:07:34 VM-4-15-debian caddy[5159]: SHELL=/bin/sh Dec 31 04:07:34 VM-4-15-debian caddy[5159]: INVOCATION_ID=fb656d0f550d4a56a12508026422a16c Dec 31 04:07:34 VM-4-15-debian caddy[5159]: JOURNAL_STREAM=9:51251 Dec 31 04:07:34 VM-4-15-debian caddy[5159]: {"level":"info","ts":1609358854.922294,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json","config_adapter":""} Dec 31 04:07:34 VM-4-15-debian caddy[5159]: {"level":"warn","ts":1609358854.9225972,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 04:07:34 VM-4-15-debian caddy[5159]: {"level":"info","ts":1609358854.9344451,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000197570"} Dec 31 04:07:34 VM-4-15-debian caddy[5159]: {"level":"info","ts":1609358854.9409463,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"} Dec 31 04:07:34 VM-4-15-debian caddy[5159]: {"level":"warn","ts":1609358854.9412005,"logger":"http","msg":"user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these redirects","server_name":"srv0","interface":"unix//dev/shm/web.sock"} Dec 31 04:07:34 VM-4-15-debian caddy[5159]: run: loading initial config: loading new config: http app module: start: unix: listening on /dev/shm/web.sock: listen unix /dev/shm/web.sock: bind: address already in use Dec 31 04:07:34 VM-4-15-debian systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE Dec 31 04:07:34 VM-4-15-debian systemd[1]: caddy.service: Failed with result 'exit-code'. Dec 31 04:09:37 VM-4-15-debian systemd[1]: Started Caddy. Dec 31 04:09:37 VM-4-15-debian caddy[5554]: caddy.HomeDir=/root Dec 31 04:09:37 VM-4-15-debian caddy[5554]: caddy.AppDataDir=/root/.local/share/caddy Dec 31 04:09:37 VM-4-15-debian caddy[5554]: caddy.AppConfigDir=/root/.config/caddy Dec 31 04:09:37 VM-4-15-debian caddy[5554]: caddy.ConfigAutosavePath=/root/.config/caddy/autosave.json Dec 31 04:09:37 VM-4-15-debian caddy[5554]: caddy.Version=v2.2.1 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.GOOS=linux Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.GOARCH=amd64 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.Compiler=gc Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.NumCPU=1 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.GOMAXPROCS=1 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: runtime.Version=go1.15.2 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: os.Getwd=/ Dec 31 04:09:37 VM-4-15-debian caddy[5554]: LANG=en_US.UTF-8 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Dec 31 04:09:37 VM-4-15-debian caddy[5554]: HOME=/root Dec 31 04:09:37 VM-4-15-debian caddy[5554]: LOGNAME=root Dec 31 04:09:37 VM-4-15-debian caddy[5554]: USER=root Dec 31 04:09:37 VM-4-15-debian caddy[5554]: SHELL=/bin/sh Dec 31 04:09:37 VM-4-15-debian caddy[5554]: INVOCATION_ID=7eee31cb71324567a85faed7ca38aa3d Dec 31 04:09:37 VM-4-15-debian caddy[5554]: JOURNAL_STREAM=9:54755 Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.403877,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json","config_adapter":""} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"warn","ts":1609358977.4057055,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.4164407,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"warn","ts":1609358977.4171467,"logger":"http","msg":"user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these redirects","server_name":"srv0","interface":"unix//dev/shm/web.sock"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.4179502,"logger":"http","msg":"port 0 listener","input_address":"unix//dev/shm/web.sock","actual_address":"/dev/shm/web.sock"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.4184408,"msg":"autosaved config","file":"/root/.config/caddy/autosave.json"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.4187117,"msg":"serving initial configuration"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.4168284,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0001af420"} Dec 31 04:09:37 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609358977.419479,"logger":"tls","msg":"cleaned up storage units"} Dec 31 04:11:18 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609359078.940561,"msg":"shutting down apps then terminating","signal":"SIGTERM"} Dec 31 04:11:18 VM-4-15-debian systemd[1]: Stopping Caddy... Dec 31 04:11:19 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609359079.4408464,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc0001af420"} Dec 31 04:11:19 VM-4-15-debian caddy[5554]: {"level":"info","ts":1609359079.440907,"msg":"shutdown done","signal":"SIGTERM"} Dec 31 04:11:19 VM-4-15-debian systemd[1]: caddy.service: Succeeded. Dec 31 04:11:19 VM-4-15-debian systemd[1]: Stopped Caddy. Dec 31 04:11:19 VM-4-15-debian systemd[1]: Started Caddy. Dec 31 04:11:19 VM-4-15-debian caddy[5863]: caddy.HomeDir=/root Dec 31 04:11:19 VM-4-15-debian caddy[5863]: caddy.AppDataDir=/root/.local/share/caddy Dec 31 04:11:19 VM-4-15-debian caddy[5863]: caddy.AppConfigDir=/root/.config/caddy Dec 31 04:11:19 VM-4-15-debian caddy[5863]: caddy.ConfigAutosavePath=/root/.config/caddy/autosave.json Dec 31 04:11:19 VM-4-15-debian caddy[5863]: caddy.Version=v2.2.1 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.GOOS=linux Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.GOARCH=amd64 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.Compiler=gc Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.NumCPU=1 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.GOMAXPROCS=1 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: runtime.Version=go1.15.2 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: os.Getwd=/ Dec 31 04:11:19 VM-4-15-debian caddy[5863]: LANG=en_US.UTF-8 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Dec 31 04:11:19 VM-4-15-debian caddy[5863]: HOME=/root Dec 31 04:11:19 VM-4-15-debian caddy[5863]: LOGNAME=root Dec 31 04:11:19 VM-4-15-debian caddy[5863]: USER=root Dec 31 04:11:19 VM-4-15-debian caddy[5863]: SHELL=/bin/sh Dec 31 04:11:19 VM-4-15-debian caddy[5863]: INVOCATION_ID=c5ad1c0c25574e58a597c737f5a29398 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: JOURNAL_STREAM=9:57333 Dec 31 04:11:19 VM-4-15-debian caddy[5863]: {"level":"info","ts":1609359079.4908628,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/caddy.json","config_adapter":""} Dec 31 04:11:19 VM-4-15-debian caddy[5863]: {"level":"warn","ts":1609359079.4911628,"logger":"admin","msg":"admin endpoint disabled"} Dec 31 04:11:19 VM-4-15-debian caddy[5863]: {"level":"info","ts":1609359079.5023687,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"} Dec 31 04:11:19 VM-4-15-debian caddy[5863]: {"level":"warn","ts":1609359079.5026233,"logger":"http","msg":"user server is listening on same interface as automatic HTTP->HTTPS redirects; user-configured routes might override these redirects","server_name":"srv0","interface":"unix//dev/shm/web.sock"} Dec 31 04:11:19 VM-4-15-debian caddy[5863]: {"level":"info","ts":1609359079.5031316,"logger":"http","msg":"enabling experimental HTTP/3 listener","addr":"/dev/shm/web.sock"} Dec 31 04:11:19 VM-4-15-debian caddy[5863]: run: loading initial config: loading new config: http app module: start: getting HTTP/3 UDP listener: listen udp: address /dev/shm/web.sock: missing port in address Dec 31 04:11:19 VM-4-15-debian systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE Dec 31 04:11:19 VM-4-15-debian systemd[1]: caddy.service: Failed with result 'exit-code'.

mholt commented 3 years ago

I see, thanks.

The key is this, I guess:

Dec 31 04:11:19 VM-4-15-debian caddy[5863]: run: loading initial config: loading new config: http app module: start: getting HTTP/3 UDP listener: listen udp: address /dev/shm/web.sock: missing port in address

Apparently you're the first person to try serving HTTP/3 over a unix socket. I wonder if we need the unixgram network for this? @marten-seemann do you happen to know how that works? Do we listen on unixgram network type for HTTP/3 over unix socket?

marten-seemann commented 3 years ago

Not sure how this works. How do you construct the packet conn you pass to quic-go (or are you using ListenAddr here?)?

mholt commented 3 years ago

Perhaps naively, we use:

https://github.com/caddyserver/caddy/blob/1b453dd4fbea2f3a54362fb4c2115bab85cad1b7/modules/caddyhttp/app.go#L354

Happy new year btw :)

marten-seemann commented 3 years ago

Happy new year @mholt!

ListenPacket returns a net.PacketConn, so I'm surprised there's an error here. Is that error originating from Caddy or from quic-go?

mholt commented 3 years ago

It's from Go std lib, not a problem with your lib, don't worry! I think it's because I'm passing a Unix socket into that function where it expects a port. So to serve http3 on a Unix socket, I am guessing the right network type is "unixgram" instead of "udp"? I am not sure, so I thought I'd ask you in case you had experience with it. I can look it up later when I'm back on after the holidays.

mholt commented 3 years ago

Another problem with this is that a unix socket can't be bound to more than one network type like a port can. So we can't bind the same socket file to both TCP and UDP. @lxhao61, I'm not sure your config is possible.

lxhao61 commented 3 years ago

thanks.

Too polite! thank you for your reply. Yes, I think it would be more efficient to use unix sockets on "listen".

lxhao61 commented 3 years ago

Another problem with this is that a unix socket can't be bound to more than one network type like a port can. So we can't bind the same socket file to both TCP and UDP. @lxhao61, I'm not sure your config is possible.

I think it should be possible. Similar situations are no problem in nginx. Of course nginx does not support http/3 applications. In addition, unix sockets support TCP and UDP.

mholt commented 3 years ago

In addition, unix sockets support TCP and UDP.

I do not believe the same socket can serve both TCP and UDP at the same time. I would love to be proven wrong, if you can show me an example how to do it in Go.

lxhao61 commented 3 years ago

In addition, unix sockets support TCP and UDP.

I do not believe the same socket can serve both TCP and UDP at the same time. I would love to be proven wrong, if you can show me an example how to do it in Go.

I checked the information roughly: a socket can serve both TCP and UDP. Sorry, I am not a software developer. I don't know how to implement it, especially in Go.

mholt commented 3 years ago

When you try to bind to a unix socket for both TCP and then UDP, it returns an error because the socket is already in use.

So without any further information, I don't think there's anything to be done here. Will close since the issue is apparently not actionable, but if new information is presented that is something we can act on, we can reopen it and someone can implement the feature you want.