<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">It seems the lock lies in the fact there is no generic way for the listen directive to specify multiple ports, so you are stuck with that much server blocks.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Now, you could use the $server_port variable in the proxy_pass directive, but that brings no real improvement.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">You could use configuration management tools to template configuration generation, relieving you of the burden of maintaing all those blocks by hand.<br></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Tue, May 31, 2016 at 11:11 AM, alajl <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have this configure file, but it is long-winded。<br>
in nginx, are there having one expression to handle it<br>
<br>
 server {<br>
        listen     <a href="http://192.168.1.2:10000" rel="noreferrer" target="_blank">192.168.1.2:10000</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10000" rel="noreferrer" target="_blank">192.168.0.3:10000</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10001" rel="noreferrer" target="_blank">192.168.1.2:10001</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10001" rel="noreferrer" target="_blank">192.168.0.3:10001</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10002" rel="noreferrer" target="_blank">192.168.1.2:10002</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10002" rel="noreferrer" target="_blank">192.168.0.3:10002</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10003" rel="noreferrer" target="_blank">192.168.1.2:10003</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10003" rel="noreferrer" target="_blank">192.168.0.3:10003</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10004" rel="noreferrer" target="_blank">192.168.1.2:10004</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10004" rel="noreferrer" target="_blank">192.168.0.3:10004</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10005" rel="noreferrer" target="_blank">192.168.1.2:10005</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10005" rel="noreferrer" target="_blank">192.168.0.3:10005</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10006" rel="noreferrer" target="_blank">192.168.1.2:10006</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10006" rel="noreferrer" target="_blank">192.168.0.3:10006</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10007" rel="noreferrer" target="_blank">192.168.1.2:10007</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10007" rel="noreferrer" target="_blank">192.168.0.3:10007</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10008" rel="noreferrer" target="_blank">192.168.1.2:10008</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10008" rel="noreferrer" target="_blank">192.168.0.3:10008</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10009" rel="noreferrer" target="_blank">192.168.1.2:10009</a>;<br>
        proxy_pass  <a href="http://192.168.0.3:10009" rel="noreferrer" target="_blank">192.168.0.3:10009</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10010" rel="noreferrer" target="_blank">192.168.1.2:10010</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10010" rel="noreferrer" target="_blank">192.168.0.4:10010</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10011" rel="noreferrer" target="_blank">192.168.1.2:10011</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10011" rel="noreferrer" target="_blank">192.168.0.4:10011</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10012" rel="noreferrer" target="_blank">192.168.1.2:10012</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10012" rel="noreferrer" target="_blank">192.168.0.4:10012</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10013" rel="noreferrer" target="_blank">192.168.1.2:10013</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10013" rel="noreferrer" target="_blank">192.168.0.4:10013</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10014" rel="noreferrer" target="_blank">192.168.1.2:10014</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10014" rel="noreferrer" target="_blank">192.168.0.4:10014</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10015" rel="noreferrer" target="_blank">192.168.1.2:10015</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10015" rel="noreferrer" target="_blank">192.168.0.4:10015</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10016" rel="noreferrer" target="_blank">192.168.1.2:10016</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10016" rel="noreferrer" target="_blank">192.168.0.4:10016</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10017" rel="noreferrer" target="_blank">192.168.1.2:10017</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10017" rel="noreferrer" target="_blank">192.168.0.4:10017</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10018" rel="noreferrer" target="_blank">192.168.1.2:10018</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10018" rel="noreferrer" target="_blank">192.168.0.4:10018</a>;<br>
    }<br>
<br>
    server {<br>
        listen     <a href="http://192.168.1.2:10019" rel="noreferrer" target="_blank">192.168.1.2:10019</a>;<br>
        proxy_pass  <a href="http://192.168.0.4:10019" rel="noreferrer" target="_blank">192.168.0.4:10019</a>;<br>
    }<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,267238,267238#msg-267238" rel="noreferrer" target="_blank">https://forum.nginx.org/read.php?2,267238,267238#msg-267238</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div><br></div></div>