<div class="zcontentRow"> <p style="line-height: 21px; white-space: normal;">now I understand the duplicate listen ports configured in the http block can be used to implement virtual hosts.</p><p style="line-height: 21px; white-space: normal;">but what's the purpose to allow this in the stream block? in my practise (with <span style="line-height: 21px;">1.9.15.1</span>), nginx will randomly select a backend to serve the tcp/udp request which seems useless.</p><p style="line-height: 21px; white-space: normal;">b.t.w, I also tried with 1.11.x today, looks like configuring duplicate listen ports in stream block is forbidden. </p><p style="line-height: 21px; white-space: normal;"><br></p><p style="line-height: 21px; white-space: normal;">BR,</p><p style="line-height: 21px; white-space: normal;">Joe</p><p><br></p><p><br></p><p><br></p><p><br></p><p style="font-family: 宋体; font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:12px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span class="signedit"><br></span></span></p><p style="font-family: 宋体; font-size: medium; line-height: normal; widows: 1;"><br></p><p style="font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:10px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span style=""><span class="signedit"><br></span></span></span></p><p style="font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:10px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"></span></p><span style="line-height: normal; widows: 1; font-size: 7.0px;;color:#58595b;font-size:10px"></span><div><div class="zhistoryRow" style="display:block"><div class="zhistoryDes" style="width: 100%; height: 28px; line-height: 28px; background-color: #E0E5E9; color: #1388FF; text-align: center;" language-data="HistoryOrgTxt">原始邮件</div><div id="zwriteHistoryContainer"><div class="control-group zhistoryPanel"><div class="zhistoryHeader" style="padding: 8px; background-color: #F5F6F8;"><strong language-data="HistorySenderTxt" style="line-height: 1.5em;">发件人:</strong><span class="zreadUserName"> <nginx-request@nginx.org>;</span></div></div><div class="control-group zhistoryPanel"><div class="zhistoryHeader" style="padding: 8px; background-color: #F5F6F8;"><div><strong language-data="HistoryTOTxt">收件人:</strong><span class="zreadUserName" style="display: inline-block;"> <nginx@nginx.org>;</span></div><div><strong language-data="HistoryDateTxt">日 期 :</strong><span class="">2017年02月13日 20:00</span></div><div><strong language-data="HistorySubjectTxt">主 题 :</strong><span class="zreadTitle"><strong>nginx Digest, Vol 88, Issue 18</strong></span></div></div><p class="zhistoryContent"><br></p><div>Send nginx mailing list submissions to<br>    nginx@nginx.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    http://mailman.nginx.org/mailman/listinfo/nginx<br>or, via email, send a message with subject or body 'help' to<br>    nginx-request@nginx.org<br><br>You can reach the person managing the list at<br>    nginx-owner@nginx.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of nginx digest..."<br><br><br>Today's Topics:<br><br>   1. RE: having nginx listen the same port more than once<br>      (Reinis Rozitis)<br>   2. Apache to nginx (Daniel)<br>   3. Re: having nginx listen the same port more than once<br>      (Igor A. Ippolitov)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Mon, 13 Feb 2017 09:13:36 +0200<br>From: "Reinis Rozitis" <r@roze.lv><br>To: <nginx@nginx.org><br>Subject: RE: having nginx listen the same port more than once<br>Message-ID: <002001d285c8$b1defca0$159cf5e0$@roze.lv><br>Content-Type: text/plain;    charset="UTF-8"<br><br>> I observe that the nginx runs with no error if there are duplicate listen ports configured in the http server block or stream server block.<br>is this behavior as expected? <br><br>That is how every webserver capable of name based virtual hosts works. <br>So yes it's normal and expected.<br><br>> and if a request comes at such a port, which server would serve this request, by radomly or round-robin?<br><br>http://nginx.org/en/docs/http/request_processing.html<br><br>rr<br><br><br><br>------------------------------<br><br>Message: 2<br>Date: Mon, 13 Feb 2017 10:23:44 +0100<br>From: Daniel <daniel@linux-nerd.de><br>To: nginx@nginx.org<br>Subject: Apache to nginx<br>Message-ID: <18E57C65-35BB-443E-AC42-DB3AC8E12CBF@linux-nerd.de><br>Content-Type: text/plain; charset="us-ascii"<br><br>Hi,<br><br>i create a vhost confuguration for a vhost but i ma not able to access /vakanz for exmaple.<br>I got a 404 error on the access logs.<br>I Tried already with rewrite rules and i also tried with locations, no matter what i do, nothing works.<br>Anyone has an idea what can i do?<br><br>Cheers<br><br>Daniel<br><br><br><br>    server {<br><br>        listen 80;<br><br>        root /var/www/vhosts/reisen/sbo/current/web;<br><br><br><br>rewrite ^/static/(.*) /var/www/vhosts/reisen/fe/static/$1 last;<br><br>rewrite ^/hrouter.js /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/router.js /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/(vakanz|vrij|ajax|boek|buchen){0}nbsp;/var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/(vakanz|vrij|ajax|boek|buchen)/.* /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/himage/.* /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/image/.* /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/images/.* /var/www/vhosts/reisen/fe/index.php last;<br><br>rewrite ^/nur-flug{0}nbsp;/flight/destination permanent;<br><br><br><br><br><br>        set $my_https "off";<br><br>        if ($http_x_forwarded_proto = "https") {<br><br>            set $my_https "on";<br><br>        }<br><br>        server_name preprod.reisen.de;<br><br><br><br>        location / {<br><br>            index app.php;<br><br>            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";<br><br>            add_header Access-Control-Allow-Origin "*";<br><br>            if (-f $request_filename) {<br><br>                break;<br><br>            }<br><br>            try_files $uri @rewriteapp;<br><br>        }<br><br><br><br>        location @rewriteapp {<br><br>            if ( $request_filename !~ opcache\.php  ){<br><br>            rewrite ^(.*){0}nbsp;/app.php/$1 last;<br><br>        }<br><br>            }<br><br><br><br><br><br>#rewrite ^/(vakanz|vrij|ajax|boek|buchen){0}nbsp;/var/www/vhosts/reisen/fe/index.php last;<br><br>#rewrite ^/(vakanz|vrij|ajax|boek|buchen)/.* /var/www/vhosts/reisen/fe/index.php last;<br><br><br><br><br><br># location /vakanz {<br><br>#    alias /var/www/vhosts/reisen/fe/;<br><br>#  }<br><br><br><br>location ~* .js$<br><br>      {add_header  Service-Worker-Allowed "/";<br><br>       }<br><br><br><br>        location ~ ^/app\.php/_apilogger(/|$) {<br><br>    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;<br><br>            fastcgi_split_path_info ^(.+\.php)(/.*)$;<br><br>            include fastcgi_params;<br><br>            fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br><br>            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br><br>            fastcgi_param PATH_INFO $fastcgi_path_info;<br><br>            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;<br><br>            fastcgi_param HTTPS $my_https;<br><br>    fastcgi_param SYMFONY__CMS__ENABLED false;<br><br>            fastcgi_param CMS_ENABLED false;<br><br>            fastcgi_buffer_size 128k;<br><br>            fastcgi_buffers 4 256k;<br><br>            fastcgi_busy_buffers_size 256k;<br><br>            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";<br><br>            add_header Access-Control-Allow-Origin "*";<br><br><br><br>            # Prevents URIs that include the front controller. This will 404:<br><br>            # http://domain.tld/app.php/some-path<br><br>            # Remove the internal directive to allow URIs like this<br><br>            internal;<br><br>        }<br><br><br><br>       location ~ ^/proxy\.php(\?|/|$) {<br><br>    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;<br><br>            fastcgi_split_path_info ^(.+\.php)(.*)$;<br><br>            include fastcgi_params;<br><br>            fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br><br>            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br><br>            fastcgi_param PATH_INFO $fastcgi_path_info;<br><br>            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;<br><br>            fastcgi_param HTTPS $my_https;<br><br>    fastcgi_param SYMFONY__CMS__ENABLED false;<br><br>            fastcgi_param CMS_ENABLED false;<br><br>            fastcgi_buffer_size 128k;<br><br>            fastcgi_buffers 4 256k;<br><br>            fastcgi_busy_buffers_size 256k;<br><br>            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";<br><br>            add_header Access-Control-Allow-Origin "*";<br><br>            # Prevents URIs that include the front controller. This will 404:<br><br>            # http://domain.tld/app.php/some-path<br><br>            # Remove the internal directive to allow URIs like this<br><br>            #internal;<br><br>        }<br><br><br><br>        location ~ ^/app\.php(/|$) {<br><br>    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;<br><br>            fastcgi_split_path_info ^(.+\.php)(/.*)$;<br><br>            include fastcgi_params;<br><br>            fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br><br>            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br><br>            fastcgi_param PATH_INFO $fastcgi_path_info;<br><br>            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;<br><br>            fastcgi_param HTTPS $my_https;<br><br>    fastcgi_param SYMFONY__CMS__ENABLED false;<br><br>            fastcgi_param CMS_ENABLED false;<br><br>            fastcgi_buffer_size 128k;<br><br>            fastcgi_buffers 4 256k;<br><br>            fastcgi_busy_buffers_size 256k;<br><br>            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";<br><br>            add_header Access-Control-Allow-Origin "*";<br><br><br><br>            # Prevents URIs that include the front controller. This will 404:<br><br>            # http://domain.tld/app.php/some-path<br><br>            # Remove the internal directive to allow URIs like this<br><br>            internal;<br><br>        }<br><br><br><br><br><br>    }<br><br><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170213/b191c527/attachment-0001.html><br><br>------------------------------<br><br>Message: 3<br>Date: Mon, 13 Feb 2017 14:42:22 +0300<br>From: "Igor A. Ippolitov" <iippolitov@nginx.com><br>To: nginx@nginx.org<br>Subject: Re: having nginx listen the same port more than once<br>Message-ID: <be38a1be-d5e2-de09-688f-642326c5caeb@nginx.com><br>Content-Type: text/plain; charset=windows-1252; format=flowed<br><br>Assuming a configuration with multiple similar 'listen' and <br>'server_name' statements, only the first one will work:<br>>     server {<br>>         listen 9090;<br>>         return 404;<br>>         server_name example.com;<br>>     }<br>>     server {<br>>         listen 9090;<br>>         return 403;<br>>         server_name example.com;<br>>     }<br>>     server {<br>>         listen 9090;<br>>         return 400;<br>>         server_name example.com;<br>>     }<br><br>> nginx: [warn] conflicting server name "example.com" on 0.0.0.0:9090, <br>> ignored<br>> nginx: [warn] conflicting server name "example.com" on 0.0.0.0:9090, <br>> ignored <br>Afaik, the only reply you would be able to get from such configuration <br>is '404'<br><br>On 13.02.2017 10:13, Reinis Rozitis wrote:<br>>> I observe that the nginx runs with no error if there are duplicate listen ports configured in the http server block or stream server block.<br>> is this behavior as expected?<br>><br>> That is how every webserver capable of name based virtual hosts works.<br>> So yes it's normal and expected.<br>><br>>> and if a request comes at such a port, which server would serve this request, by radomly or round-robin?<br>> http://nginx.org/en/docs/http/request_processing.html<br>><br>> rr<br>><br>> _______________________________________________<br>> nginx mailing list<br>> nginx@nginx.org<br>> http://mailman.nginx.org/mailman/listinfo/nginx<br><br><br><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>nginx mailing list<br>nginx@nginx.org<br>http://mailman.nginx.org/mailman/listinfo/nginx<br><br>------------------------------<br><br>End of nginx Digest, Vol 88, Issue 18<br>*************************************<br></div><p><br></p></div></div></div></div><p><br></p> </div>