1

I have a server which serves some other systems via LXD, using Nginx as reverse proxy for accessing them on HTTP.

Now I want to give shell access to one of them to a friend. In fact, I want to be able to directly SSH into LXD machine, without connecting to main server via SSH first.

I used stream function of Nginx as following:

stream {
upstream ssh {
    server 240.17.0.16:22;
}

server {
    listen 22;
    server_name bbb.flossir.org;
    proxy_pass ssh;
}
}

But Nginx says that it cannot process server_name in stream section:

nginx: [emerg] "server_name" directive is not allowed here in /etc/nginx/streams-enabled/bigbluebutton:7

What should I do?

1 Answer 1

2

Remove the server_name directive. There is no such thing for the stream module as you can see at https://nginx.org/en/docs/stream/ngx_stream_core_module.html

Think about it, the stream module provides generic TCP proxy functionality. TCP has no concept of host names for virtual hosting, unlike the HTTP Host header, or TLS Server Name Indication (SNI) extension.

If you meant to bind to the public IP address of bbb.flossir.org as opposed to the wildcard address, use:

listen bbb.flossir.org:22;

See https://nginx.org/en/docs/stream/ngx_stream_core_module.html#listen

2
  • There is no separate IP address for bbb. All LXD machines share the same public IP address and Nginx proxies them to the local IP for HTTP connection. I just want to do the same for ssh connections as well. Mar 16, 2020 at 6:46
  • 2
    You cannot do that with SSH for the reasons mentioned in the post, there is no way to use the host name for selecting the backend for SSH. You have to use either different ports, or different IP addresses. If IPv6 is supported, that would be a viable option where you assign a unique IPv6 address to every domain name.
    – Lekensteyn
    Mar 16, 2020 at 22:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .