Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support multiple ports like stream listen in http and https listen port. #1195

Closed
wwd5613 opened this issue Mar 4, 2020 · 15 comments · Fixed by #2409
Closed

feature: support multiple ports like stream listen in http and https listen port. #1195

wwd5613 opened this issue Mar 4, 2020 · 15 comments · Fixed by #2409
Assignees
Labels
enhancement New feature or request

Comments

@wwd5613
Copy link
Contributor

wwd5613 commented Mar 4, 2020

No description provided.

@wwd5613 wwd5613 changed the title feature:: support multiple ports like stream listen in http and https listen port. feature: support multiple ports like stream listen in http and https listen port. Mar 4, 2020
@membphis membphis added enhancement New feature or request beginner labels Mar 4, 2020
@membphis
Copy link
Member

membphis commented Mar 4, 2020

Very good advice

@moonming
Copy link
Member

moonming commented Mar 4, 2020

@wwd5613 welcome PR

@soulsoul
Copy link
Member

soulsoul commented Mar 7, 2020

@wwd5613 can u show some example?

@soulsoul
Copy link
Member

soulsoul commented Mar 7, 2020

that means: you want apisix can support multiple ports to start. now apisix just can start up on one port by the config parameter "node_listen ". just for the configuration in nginx
server {
listen 9080 9081 9082;
listen 9443 ssl https2;
}
is it right ?
@wwd5613

@tzssangglass
Copy link
Member

I want to solve this issues. This is my first time to participate in apisix.
Can I choose @membphis as a mentor.
The deadline I gave is October 18.

@membphis
Copy link
Member

@tzssangglass no problem. I have assigned this issue to you. If you have any questions, please feel free to talk to me.

@tzssangglass
Copy link
Member

@tzssangglass no problem. I have assigned this issue to you. If you have any questions, please feel free to talk to me.

ok

@tzssangglass
Copy link
Member

now i modified config.yaml as follows

apisix:
  node_listen:
    - 9080
    - 9081
    - 9082

and modified the ngx_tpl related places, as follows

        {% for _, port in ipairs(node_listen) do %}
        listen {* port *} {% if enable_reuseport then %} reuseport {% end %};
        {% end %}
        ……
        {% for _, port in ipairs(node_listen) do %}
        listen [::]:{* port *} {% if enable_reuseport then %} reuseport {% end %};
        {% end %}

in this way config.yaml can be parsed as the following configuration in nginx.conf

        listen 9080 reuseport;
        listen 9081 reuseport;
        listen 9082 reuseport;
        ……
        listen [::]:9080 reuseport;
        listen [::]:9081 reuseport;
        listen [::]:9082 reuseport;

now my question is

  • Is it compatible with the original configuration of node_listen and separated by commas
  • Expansion 9080 and 9443 port

@membphis
Copy link
Member

support multiple listening ports, there are three styles:

style 1

apisix:
  node_listen:
    - 9080
    - 9081
    - 9082

style 2

apisix:
  node_listen: 9080 9081 9082

style 3

apisix:
  node_listen: 9080, 9081, 9082

Which is the one you would like?
I vote to 2 and 3.

@tzssangglass
Copy link
Member

I vote to 3

  • downward compatibility
  • reduced ambiguity

@moonming
Copy link
Member

Apache APISIX is now using style 1, I think it should be consistent, this is also a more common way in yaml

@tzssangglass
Copy link
Member

tzssangglass commented Oct 12, 2020

Apache APISIX is now using style 1, I think it should be consistent, this is also a more common way in yaml

In master branch,node_listen is not using style 1,

apisix:
node_listen: 9080 # APISIX listening port

but stream_proxy is using style 1,

# stream_proxy: # TCP/UDP proxy
# tcp: # TCP proxy port list
# - 9100

so without considering backward compatibility,node_listen change to style 1 is the most suitable.

the question now is whether to consider backward compatibility, i cannot make a decision on my own.

@tzssangglass
Copy link
Member

Or take a more complicated method, compatible with the original configuration method. If you need to support multiple ports like stream listen in http and https listen port,modify config.yaml like style 1.

@membphis
Copy link
Member

Apache APISIX is now using style 1,

APISIX is using style 2 or 3 (only one port) currently.

@tzssangglass
Copy link
Member

I think the compatibility design is reasonable, I plan to do this.
If the user want to support multiple listen, they need to modify config.yaml like style 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants