"tcp" directive is not allowed here #51

Closed
tanepiper opened this Issue Aug 9, 2012 · 3 comments

Comments

Projects
None yet
4 participants
@tanepiper

Hi there,

I have a websocket application that runs on a port on the local machine - I've recompiled nginx 1.2.3 with the TCP module, and have created a file for sites-enabled/dashboard.conf.

The file is as follows:

tcp {
    upstream websockets {
        server 127.0.0.1:35005;
        server 127.0.0.1:35005;

        check interval=3000 rise=2 fall=5 timeout=1000;
    }

    server {
        listen  1270.0.01:80;
        server_name     dashboard.foo.com;
        access_log      /var/log/nginx/foo.dashboard.access.log;

        tcp_nodelay on;
        proxy_pass websockets
    }
}

However I get an error:

Restarting nginx: nginx: [emerg] "tcp" directive is not allowed here in /etc/nginx/sites-enabled/dashboard.conf:1

This server runs multiple subdomains for this application, with the dashboard subdomain being the only one currently needing websockets.

Any ideas how I can get this working?

@yaoweibin

This comment has been minimized.

Show comment Hide comment
@yaoweibin

yaoweibin Aug 9, 2012

Owner

The tcp listened port can't use the same port as the HTTP port. The tcp
block is used in the main block, not in the http block.

Maybe you can try the websocket mode in the tcp proxy module:
https://github.com/yaoweibin/nginx_tcp_proxy_module/wiki/websocket

On 2012-8-9 18:53, Tane Piper wrote:

Hi there,

I have a websocket application that runs on a port on the local
machine - I've recompiled nginx 1.2.3 with the TCP module, and have
created a file for sites-enabled/dashboard.conf.

The file is as follows:

|tcp {
upstream websockets {
server 127.0.0.1:35005;
server 127.0.0.1:35005;

     check interval=3000 rise=2 fall=5 timeout=1000;
 }

 server {
     listen  1270.0.01:80;
     server_name     dashboard.foo.com;
     access_log      /var/log/nginx/foo.dashboard.access.log;

     tcp_nodelay on;
     proxy_pass websockets
 }

}
|

However I get an error:

Restarting nginx: nginx: [emerg] "tcp" directive is not allowed here
in /etc/nginx/sites-enabled/dashboard.conf:1

This server runs multiple subdomains for this application, with the
dashboard subdomain being the only one currently needing websockets.

Any ideas how I can get this working?


Reply to this email directly or view it on GitHub
#51.

Thanks,
-Weibin Yao

Owner

yaoweibin commented Aug 9, 2012

The tcp listened port can't use the same port as the HTTP port. The tcp
block is used in the main block, not in the http block.

Maybe you can try the websocket mode in the tcp proxy module:
https://github.com/yaoweibin/nginx_tcp_proxy_module/wiki/websocket

On 2012-8-9 18:53, Tane Piper wrote:

Hi there,

I have a websocket application that runs on a port on the local
machine - I've recompiled nginx 1.2.3 with the TCP module, and have
created a file for sites-enabled/dashboard.conf.

The file is as follows:

|tcp {
upstream websockets {
server 127.0.0.1:35005;
server 127.0.0.1:35005;

     check interval=3000 rise=2 fall=5 timeout=1000;
 }

 server {
     listen  1270.0.01:80;
     server_name     dashboard.foo.com;
     access_log      /var/log/nginx/foo.dashboard.access.log;

     tcp_nodelay on;
     proxy_pass websockets
 }

}
|

However I get an error:

Restarting nginx: nginx: [emerg] "tcp" directive is not allowed here
in /etc/nginx/sites-enabled/dashboard.conf:1

This server runs multiple subdomains for this application, with the
dashboard subdomain being the only one currently needing websockets.

Any ideas how I can get this working?


Reply to this email directly or view it on GitHub
#51.

Thanks,
-Weibin Yao

@shuge

This comment has been minimized.

Show comment Hide comment
@shuge

shuge Oct 23, 2012

Please update your wiki with following schema, it is more clear.

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    ...
    #include /data/services/nginx_vhost/*.conf;
}

include /data/services/nginx_vhost/tcp_proxy_test.conf;

shuge commented Oct 23, 2012

Please update your wiki with following schema, it is more clear.

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    ...
    #include /data/services/nginx_vhost/*.conf;
}

include /data/services/nginx_vhost/tcp_proxy_test.conf;
@giasek

This comment has been minimized.

Show comment Hide comment
@giasek

giasek Sep 2, 2015

Can You, please, explain how to use auth_basic, auth_basic_user_file inside tcp block ?

giasek commented Sep 2, 2015

Can You, please, explain how to use auth_basic, auth_basic_user_file inside tcp block ?

@tanepiper tanepiper closed this Oct 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment