How to operate this TURN/STUN server behind Nginx

6,419 views
Skip to first unread message

Jo Yum

unread,
Jun 15, 2015, 5:23:47 PM6/15/15
to turn-server-project...@googlegroups.com
Hello all,

Is it possible to operate this TURN/STUN server on Linux behind Nginx?

If so, can you show a working Nginx config for that setup?

For example, would this Nginx config work?
upstream turn_server {
server 111.222.333.444:5000;
}

server {
listen 80;
server_name example.com;
root /home/public_html/example.com;

location /turn {
client_max_body_size 128k;
client_body_buffer_size 256k;
proxy_connect_timeout 70s;
proxy_send_timeout 65s;
proxy_read_timeout 65s;
proxy_buffer_size 8k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_ignore_client_abort on;
proxy_pass http://turn_server;
proxy_redirect off;
}
}

server {
listen 443 ssl;
server_name example.com;
root /home/public_html/example.com;

ssl_prefer_server_ciphers on;
ssl_protocols            TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers              aRSA:!eNULL:!EXP:!LOW:-RC4:-3DES:!SEED:!MD5:!kPSK:!kSRP:-kRSA:@STRENGTH:AES128-SHA:DES-CBC3-SHA:RC4-SHA;
ssl_session_cache        shared:TLSSL:16m;
ssl_session_timeout      10m;
ssl_certificate          /etc/nginx/ssl/example.com.crt;
ssl_certificate_key      /etc/nginx/ssl/example.com.key;
location /turn {
client_max_body_size 128k;
client_body_buffer_size 256k;
proxy_connect_timeout 70s;
proxy_send_timeout 65s;
proxy_read_timeout 65s;
proxy_buffer_size 8k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_ignore_client_abort on;
proxy_pass http://turn_server;
proxy_redirect off;
}
}

In the above Nginx config, the STUN server is running on port 5000, but from the Internet it's only accessible through ports 80 or 443.

Thank you

Jo Yum

unread,
Jun 17, 2015, 10:44:53 AM6/17/15
to turn-server-project...@googlegroups.com
Hello,

Does anyone know if the TURN server can operate properly on a Linux machine running an Nginx reverse proxy to Apache?

Thank you

Jo Yum

unread,
Jun 17, 2015, 11:28:40 AM6/17/15
to turn-server-project...@googlegroups.com
To anyone,

TURN can be configured for TCP or UDP transport.

But aside from the TURN transport config (UDP or TCP), if TURN is listening on port 3478, and Nginx is listening on 80 and 443, and Apache on 81, wouldn't TURN get packets from WebRTC directly without Nginx or Apache seeing those packets?

abdul basit

unread,
Feb 28, 2018, 8:33:42 PM2/28/18
to TURN Server (Open-Source project)
Hi, were you able to find a solution? 

Nitin Dhami

unread,
Feb 8, 2021, 5:30:23 AM2/8/21
to TURN Server (Open-Source project)
Hi, can anyone share their version of the config file for config files in Nginx?

mm28

unread,
May 14, 2021, 2:01:56 PM5/14/21
to TURN Server (Open-Source project)
Maybe this helps. Have not tried it myself yet.

Reply all
Reply to author
Forward
0 new messages