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

Port check in standalone mode #3624

Closed
Vorticity-Flux opened this issue Jul 25, 2021 · 7 comments
Closed

Port check in standalone mode #3624

Vorticity-Flux opened this issue Jul 25, 2021 · 7 comments

Comments

@Vorticity-Flux
Copy link

I have a multi-homed server with separate public and private network interfaces. Web server on port 80 is running on private network, port 80 is available on public network.
I try to issue new certificate with acme.sh --issue --standalone --local-address <public_IP> -d x.y.z but it fails with

[Sun Jul 25 21:25:12 UTC 2021] Standalone mode.
[Sun Jul 25 21:25:12 UTC 2021] _checkport='80'
[Sun Jul 25 21:25:12 UTC 2021] _checkaddr='<public_IP>'
[Sun Jul 25 21:25:12 UTC 2021] Using: ss
[Sun Jul 25 21:25:12 UTC 2021] LISTEN0      128                         <private_IP>:80           0.0.0.0:*     users:(("nginx",pid=19107,fd=6),("nginx",pid=19105,fd=6),("nginx",pid=19104,fd=6),("nginx",pid=19103,fd=6),("nginx",pid=19101,fd=6))
[Sun Jul 25 21:25:12 UTC 2021] tcp port 80 is already used by (("nginx",pid=19107,fd=6),("nginx",pid=19105,fd=6),("nginx",pid=19104,fd=6),("nginx",pid=19103,fd=6),("nginx",pid=19101,fd=6))
[Sun Jul 25 21:25:12 UTC 2021] Please stop it first
[Sun Jul 25 21:25:12 UTC 2021] _on_before_issue.

Commenting check for LOCAL_ANY_ADDRESS in _on_before_issue allows process to continue and certificate is issued successfully.

acme.sh/acme.sh

Line 3443 in a199fc6

if [ -z "$netprc" ]; then

@montaniasystemab
Copy link

I can confirm this issue, the check for open ports does not consider the option Le_LocalAddress and denies renewal if the port is open on any IP address

@Neilpang
Copy link
Member

This is intended.

If a process(nginx) is listening on any address "0.0.0.0:80", another process should not try to listen at any one local ipaddress "x,y,z,w".

The second listener will have unexpected behavior, it's not guaranteed that the second listener can always get socket messages.

@montaniasystemab
Copy link

I'm not sure that you are describing the issue that we're having. We have a process listening on a specific IP address and would like for acme.sh to listen on another IP address.

We do not have a process listening on 0.0.0.0:80 but rather 10.0.0.1:80 and would like acme.sh use 10.0.0.2:80

@Neilpang
Copy link
Member

@montaniasystemab Your issue is not the one that @Vorticity-Flux discribed.

@Neilpang
Copy link
Member

We do not have a process listening on 0.0.0.0:80 but rather 10.0.0.1:80 and would like acme.sh use 10.0.0.2:80

This is supported, I'm sure.

@Vorticity-Flux
Copy link
Author

Vorticity-Flux commented Jul 27, 2021

We do not have a process listening on 0.0.0.0:80 but rather 10.0.0.1:80 and would like acme.sh use 10.0.0.2:80

Exactly this. My web server process is listening on <private_ip>:80. No process is listening on 0.0.0.0:80 or <public_ip>:80.
Sorry if my initial description was not clear.

The problem is in the line:

acme.sh/acme.sh

Line 3444 in a199fc6

netprc="$(echo "$_netprc" | grep "$LOCAL_ANY_ADDRESS")"

It uses grep to check for presence of 0.0.0.0, however this address is present in every line of ss -ntpl output in the Peer Address column.

# ss -ntpl 
State       Recv-Q       Send-Q                                Local Address:Port               Peer Address:Port                                                                                                                               
LISTEN      0            128                                    <private_IP>:80                      0.0.0.0:*           users:(("nginx",pid=19101,fd=6),("nginx",pid=4231,fd=6),("nginx",pid=4230,fd=6),("nginx",pid=4229,fd=6),("nginx",pid=4228,fd=6))

Neilpang added a commit that referenced this issue Jul 28, 2021
@Neilpang
Copy link
Member

please try again with latest dev branch.

acme.sh  --upgrade -b dev

Sp1l pushed a commit to Sp1l/acme.sh that referenced this issue Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants