See:
https://www.zaproxy.org/faq/how-do-you-find-out-what-key-to-use-to-set-a-config-value-on-the-command-line/
Once you add the public address as alias you should be able to access it.
Best regards.
On 02/10/2023 01:47, Luis Matos wrote:
> Update 🚨
>
> I'm running this command now
>
> *docker run --name zap_api -u zap -p 8080:8080 -d
> api.key=123456789*
>
> and now I can access the service in the host.
>
> - Outside the server (❌):
> -
http://public-ip-server:8080
> - Failed to read
http://XXXXX:8080/ within 20 seconds, check to see
> if the site is available and if so consider adjusting ZAP's read time out
> in the Connection options panel.
> - In the host the server (✅):
> - curl
http://localhost:8080
>
> El domingo, 1 de octubre de 2023 a las 19:33:10 UTC-4, Luis Matos escribió:
>
>> Also, I want to mention, that locally (in my local PC), everything works
>> as expected*
>>
>> El domingo, 1 de octubre de 2023 a las 19:27:48 UTC-4, Luis Matos escribió:
>>
>>> Hi *thc202*,
>>>
>>> Thanks for your response, I appreciate it.
>>>
>>> Let me give you more information about this topic.
>>>
>>> I'm running this command to test the API in a cloud Linux server.
>>>
>>> *docker run --name zap_api -u zap -p 8080:8080 -d
>>>
ghcr.io/zaproxy/zaproxy:stable <
http://ghcr.io/zaproxy/zaproxy:stable>
>>> zap.sh -daemon -config
api.addrs.addr.name <
http://api.addrs.addr.name>=.*
>>> -config api.addrs.addr.regex=true -config api.key=123456789*
>>> And I can't access the service thought the public IP. Even in the host
>>> server I can't access the service, but if I look inside the container, the
>>> container works.
>>>
>>> Here the test results
>>>
>>> - Outside the server (❌):
>>> -
http://public-ip-server:8080
>>> - In the host the server (❌):
>>> - curl
http://container-ip:8080
>>> - curl
http://localhost:8080
>>> - Inside the container:
>>> - curl
http://container-ip:8080 (❌ Connection refused)
>>> - curl
http://localhost:8080 (✅ ZAP API UI)
>>>
>>> This is the error message
>>>
>>>
>>> *537583 [ZAP-IO-Server-1-1738] WARN
>>> adjusting ZAP's read time out in the Connection options panel.*
>>>
>>> I have read so many docs threads, just to mention some
>>>
>>>
>>> - Failed to read
https://xxx.xxx.xxx/ within 20 seconds · Issue #6693
>>> · zaproxy/zaproxy (
github.com)
>>> <
https://github.com/zaproxy/zaproxy/issues/6693>
>>> - ZAP does not know that the address is itself, you should proxy
>>> through that address and use the zap domain. (Or rewrite the
>>> requests to match what the host/port ZAP was set to listen to.)
>>> - With curl proxy through that address instead of requesting it,
>>> then use zap domain e.g.
http://zap/ and you should be able to
>>> access the API.
>>> - Mapping to different host port not working with Docker container ·
>>> Issue #3796 · zaproxy/zaproxy (
github.com)
>>> <
https://github.com/zaproxy/zaproxy/issues/3796>
>>> - ZAP API Ability to specify domains/addresses that API will be
>>> served from · Issue #3594 · zaproxy/zaproxy (
github.com)
>>> <
https://github.com/zaproxy/zaproxy/issues/3594>
>>> - The current workaround for this is to expose the container
>>> - If you proxy through ZAP's public address you can access the API
>>> using
http://zap/, the same way you can do locally (most of the
>>> API clients should be already proxying and using the zap domain).
>>> - You need to rewrite the request to match the zap domain (that
>>> should work).
>>>
>>>
>>> Even though the comments mention what need to be done, I don't really
>>> know how I can achieve this.
>>>
>>> Related issue
>>> Timeout error running zap api in cloud. (
google.com)
>>> <
https://groups.google.com/g/zaproxy-users/c/4LLrEvS72e0>
>>> I appreciate it if you can help me with this *thc202*, thanks in advance.