Skip to content

It does not work when using the Nginx stream module for transmission #152

@xiebruce

Description

@xiebruce

let's assume my server IP is 12.34.56.78, I had bind my domain mtg.example.com to 12.34.56.78.

I run mtg like this:

/usr/local/bin/mtg run [secert] --bind 0.0.0.0:12345

I set my telegram proxy like this, and it works fine:
image

but when I use nginx stream module to transmit it to mtg, it's not working

stream {
    log_format basic '$remote_addr [$time_local] '
                 '$protocol $status $bytes_sent $bytes_received '
                 '$session_time';

    access_log /var/logs/nginx/stream_access.log basic buffer=32k;

    # Identify SNI
    map $ssl_preread_server_name $backend_name {
        mtg.example.com mtg;
        .example.com web;
        # default to web
        default web;
    }

    # mtg
    upstream mtg {
        server 127.0.0.1:12345;
    }

    # web
    upstream web {
        server 127.0.0.1:444;
    }

    # listen 443
    server {
        listen 443 reuseport;
        listen [::]:443 reuseport;
        proxy_pass  $backend_name;
        ssl_preread on;
    }
}

I also tried to set ssl certificate in the stream server, not working too

# listen 443
server {
    listen 443 reuseport;
    listen [::]:443 reuseport;
    proxy_pass  $backend_name;
    ssl_preread on;

    #ssl start
    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/private.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
    ssl_prefer_server_ciphers on;
    #ssl end
}

by the way, my ip and domain has substituted to 12.34.56.78 and mtg.example.com.

so, can someone or the author of mtg tried to make this work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions