javascript - Nginx: Proxy turn requests -
i hosting own turn-server , have configured nginx web server.
this problem:
i have javascript webrtc client needs call turn server ice candidates, turn-server running on 40501 port.
unfortunately in javascript getting cross origin request blocked error!
here's nginx called help. configured nginx listen on port 40500 , proxy requests port 40501 on turn-server running follows:
upstream turn{ server 128.199.xx.xx:40501; } server { listen 40500; server_name _; location / { proxy_pass http://turn; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection $connection_upgrade; if ($request_method = 'options') { add_header 'access-control-allow-origin' '*'; add_header 'access-control-allow-credentials' 'true'; add_header 'access-control-allow-methods' 'get, post, options'; add_header 'access-control-allow-headers' 'dnt,x-customheader,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type'; add_header 'access-control-max-age' 1728000; add_header 'content-type' 'text/plain charset=utf-8'; add_header 'content-length' 0; return 204; } if ($request_method = 'post') { add_header 'access-control-allow-origin' '*'; add_header 'access-control-allow-credentials' 'true'; add_header 'access-control-allow-methods' 'get, post, options'; add_header 'access-control-allow-headers' 'dnt,x-customheader,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type'; } if ($request_method = 'get') { add_header 'access-control-allow-origin' '*'; add_header 'access-control-allow-credentials' 'true'; add_header 'access-control-allow-methods' 'get, post, options'; add_header 'access-control-allow-headers' 'dnt,x-customheader,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type'; } } }
but did no me. cannot connect turn-sever through nginx. doing wrong? in advance!
Comments
Post a Comment