首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mercure一直绑定到端口80

Mercure一直绑定到端口80
EN

Stack Overflow用户
提问于 2022-05-10 05:03:47
回答 1查看 167关注 0票数 0

我使用Mercure hub 0.13,在我的开发机器上一切正常,但是在我的测试服务器上,中心一直试图绑定端口80,导致错误,因为nginx已经在端口80上运行。

run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: address already in use

我使用以下命令启动集线器:

代码语言:javascript
复制
MERCURE_PUBLISHER_JWT_KEY=$(cat publisher.key.pub) \
MERCURE_PUBLISHER_JWT_ALG=RS256 \
MERCURE_SUBSCRIBER_JWT_KEY=$(cat publisher.key.pub) \
MERCURE_SUBSCRIBER_JWT_ALG=RS256 \
./mercure run -config Caddyfile.dev

Caddyfile.dev如下:

代码语言:javascript
复制
# Learn how to configure the Mercure.rocks Hub on https://mercure.rocks/docs/hub/config
{
        {$GLOBAL_OPTIONS}
}

{$SERVER_NAME:localhost:3000}

log

route {
        redir / /.well-known/mercure/ui/
        encode zstd gzip

        mercure {
                # Transport to use (default to Bolt)
                transport_url {$MERCURE_TRANSPORT_URL:bolt://mercure.db}
                # Publisher JWT key
                publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
                # Subscriber JWT key
                subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
                # Permissive configuration for the development environment
                cors_origins *
                publish_origins *
                demo
                anonymous
                subscriptions
                # Extra directives
                {$MERCURE_EXTRA_DIRECTIVES}
        }

        respond /healthz 200

        respond "Not Found" 404
}

当我将SERVER_NAME作为环境变量提供时,没有域的SERVER_NAME=:3000,集线器实际上在端口3000上启动,但运行在http模式下,这只允许匿名订阅,而不是我所需要的。

服务器:

代码语言:javascript
复制
Operating System: CentOS Stream 8
Kernel: Linux 4.18.0-383.el8.x86_64
Architecture: x86-64

尝试启动Mercure集线器时的完整输出:

代码语言:javascript
复制
2022/05/10 04:50:29.605 INFO    using provided configuration    {"config_file": "Caddyfile.dev", "config_adapter": ""}
2022/05/10 04:50:29.606 WARN    input is not formatted with 'caddy fmt' {"adapter": "caddyfile", "file": "Caddyfile.dev", "line": 3}
2022/05/10 04:50:29.609 INFO    admin   admin endpoint started  {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2022/05/10 04:50:29.610 INFO    http    enabling automatic HTTP->HTTPS redirects    {"server_name": "srv0"}
2022/05/10 04:50:29.610 INFO    tls.cache.maintenance   started background certificate maintenance  {"cache": "0xc0003d6150"}
2022/05/10 04:50:29.627 INFO    tls cleaning storage unit   {"description": "FileStorage:/root/.local/share/caddy"}
2022/05/10 04:50:29.628 INFO    tls finished cleaning storage units
2022/05/10 04:50:29.642 INFO    pki.ca.local    root certificate is already trusted by system   {"path": "storage:pki/authorities/local/root.crt"}
2022/05/10 04:50:29.643 INFO    tls.cache.maintenance   stopped background certificate maintenance  {"cache": "0xc0003d6150"}
run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: address already in use
EN

回答 1

Stack Overflow用户

发布于 2022-08-28 07:31:03

我有点晚了,但我希望这会对某人有所帮助。

正如提到的这里,您可以在caddy配置文件中手动指定http_port

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72180964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档