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

Run wp2static on Kubernetes (unprivileged container) #903

Open
drustan opened this issue Aug 2, 2023 · 1 comment
Open

Run wp2static on Kubernetes (unprivileged container) #903

drustan opened this issue Aug 2, 2023 · 1 comment

Comments

@drustan
Copy link

drustan commented Aug 2, 2023

For context, I have set up WordPress on Kubernetes using the Bitnami HELM chart. My goal is to be able to run a Kubernetes Job to execute a wp2static export.

The problem is that since executing containers as root in Kubernetes is discouraged, it prevents you from binding your web server (Apache) to ports 80/443. As an alternative, the container runs Apache on ports 8080/6443. To expose your website on ports 80/443 to the outside world, you then use an Ingress object, which basically is a TLS reverse proxy, to forward traffic to the container.

Considering this, when I run "wp2static detect" within my Wordpress container, I get this error:
'''
$ wp wp2static detect
[2023-08-02T16:58:01+02:00] Starting to detect WordPress site URLs.
[02-Aug-2023 14:58:01 UTC] PHP Fatal error: Uncaught WP2StaticGuzzleHttp\Exception\ConnectException: cURL error 7: Failed to connect to 127.0.0.1 port 443: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://127.0.0.1/robots.txt in /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlFactory.php:210
'''

After some research, I tried to find a workaround with this :
'''
$ wp --path=/ --http=https://127.0.0.1:6443 wp2static detect
Error: Failed to get url 'https://127.0.0.1:6443': cURL error 60: SSL certificate problem: self signed certificate.
'''
Unfortunately, I feel like I'm stuck here.

Do you see any easy workaround to this situation?

A potential workaround to address this would be to implement additional arguments into the wp2static CLI. One approach would be to allow users to set the address, port, and to bypass certificate verification directly from the command line.

For example, it could be something like this:

$ wp wp2static detect --address 127.0.0.1 --port 6443 --insecure
@drustan
Copy link
Author

drustan commented Aug 7, 2023

I see a reference to a variable wp2static_curl_port :

'wp2static_curl_port',

I don't see any mention of that in the documentation. How can I use it with the wp-cli command to set an alternative port?

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

1 participant