I have compiled nginx with the tcp_proxy_module by following this guide : https://stackoverflow.com/questions/12102110/nginx-to-reverse-proxy-websockets-and-enable-ssl-wss

What I want to do is to be able to forward :

TCP  url1.com:443 --forward to websocket--> 1234
HTTP url2.com:443 proxy localhost:1235
HTTP url3.com:443 proxy localhost:1236

The HTTP part works as expected since it's a different server_name. But the problem is with the TCP proxy, i'm getting :

Starting nginx: nginx: [emerg] bind() to failed (98: Address already in use)

How would I achieve that goal ?

-- edit : from the module's github https://github.com/yaoweibin/nginx_tcp_proxy_module

You can't use the same listening port with HTTP modules.

closed as off-topic by Jenny D, Iain, MichelZ, sciurus, andol Apr 2 '14 at 19:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Jenny D, Iain, MichelZ, sciurus, andol
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Like the documentation says, you can't do that. It makes as much sense as two different people using the same telephone to call two different persons at the same time. – Jenny D Apr 2 '14 at 17:24
  • It can't be done this way I know, I posted myself the answer... Maybe there's an alternative with some other tool ? – Bastien974 Apr 2 '14 at 17:56
  • I don't know how to put it any clearer - it doesn't work because it doesn't work because that's not how it works. – Jenny D Apr 2 '14 at 17:58
  • I configured nginx on a second server to proxy. Guess it's the only way.. – Bastien974 Apr 2 '14 at 18:18
  • @Bastien974 Another option could be to setup a second ip address to your network interface. – krisFR Apr 2 '14 at 18:26

As you mentionned, from the doc :

Note, You can't use the same listening port with HTTP modules.

So, what you want to do is not possible.

An option could be to setup a second IP address on your network interface.

let's say that :

  • is the primary ip (that will serve your HTTPS web site)
  • is the secondary ip (that will serve your TCP websocket)

    tcp {
       upstream websockets {
       server {
         server_name url1.com;
    http {
       server {
          server_name  url2.com;
       server {
          server_name  url3.com;

Not the answer you're looking for? Browse other questions tagged or ask your own question.