Giter VIP home page Giter VIP logo

Comments (6)

dzasa avatar dzasa commented on September 12, 2024 1

That worked, thank you :).

from frankenphp.

dunglas avatar dunglas commented on September 12, 2024

I don't see how it's related to FrankenPHP. If it works with a standard PHP build, it should work with FrankenPHP as well. If it's not the case, could you provide a reproducer (if possible a minimal Docker image) and the related logs?

Thanks.

from frankenphp.

dzasa avatar dzasa commented on September 12, 2024

Thanks @dunglas for fast response :). It might not be improvement, I thought so it was, but more like "I dont know how to implement it with frankenphp".

This is instruction how to make it work with PHP
https://github.com/lwthiker/curl-impersonate/blob/main/docs/03_LIBCURL_IMPERSONATE_PHP.md

And as I take frankenphp in dockerfile
FROM dunglas/frankenphp:1-php8.3 AS php_upstream

I managed to make it work with php with

RUN git clone https://github.com/lwthiker/curl-impersonate.git
WORKDIR curl-impersonate
RUN mkdir build
WORKDIR build
RUN ../configure
RUN make chrome-build
RUN make chrome-install
RUN ldconfig
WORKDIR /app/curl-impersonate
RUN rm -Rf build

RUN patchelf --set-soname libcurl.so /usr/local/lib/libcurl-impersonate-chrome.so
RUN echo "/usr/local/lib/libcurl-impersonate-chrome.so" > /etc/ld.so.preload

And when I run

php -r 'print_r(curl_version());'

It gives me

[ssl_version] => BoringSSL

But when I make http request which is handled by frankenphp it does not return info via libcurl-impersonate, but via original libcurl

from frankenphp.

withinboredom avatar withinboredom commented on September 12, 2024

Can you please share a dockerfile that reproduces the issue and shows what you're trying to do? Trying to piece together one from your post is error-prone.

Is this a docker file that reproduces the issue?

FROM dunglas/frankenphp:1-php8.3 AS php_upstream
RUN git clone https://github.com/lwthiker/curl-impersonate.git
WORKDIR curl-impersonate
RUN mkdir build
WORKDIR build
RUN ../configure
RUN make chrome-build
RUN make chrome-install
RUN ldconfig
WORKDIR /app/curl-impersonate
RUN rm -Rf build

RUN patchelf --set-soname libcurl.so /usr/local/lib/libcurl-impersonate-chrome.so
RUN echo "/usr/local/lib/libcurl-impersonate-chrome.so" > /etc/ld.so.preload
RUN php -r 'print_r(curl_version());'
RUN frankenphp # some script?

from frankenphp.

dzasa avatar dzasa commented on September 12, 2024

I managed to make it work. Everything is ok with Frankenphp, I just did not realize that frankenphp must be rebuilt after adding curl impersonate.

Here is working dockerfile

FROM dunglas/frankenphp:1.2-builder-php8.3 AS frankenphp_builder

## install curl-imperonate
RUN set -eux; \
    apt-get update && apt-get install --no-install-recommends -y \
        git \
        build-essential \
        pkg-config \
        cmake \
        ninja-build \
        curl \
        autoconf \
        automake \
        libtool \
        golang-go \
        unzip \
        patchelf \
        vim \
    ;

RUN git clone https://github.com/lwthiker/curl-impersonate.git
WORKDIR curl-impersonate
RUN mkdir build
WORKDIR build
RUN ../configure
RUN make chrome-build
RUN make chrome-install
RUN ldconfig
WORKDIR /app/curl-impersonate
RUN rm -Rf build

RUN patchelf --set-soname libcurl.so /usr/local/lib/libcurl-impersonate-chrome.so
RUN echo "/usr/local/lib/libcurl-impersonate-chrome.so" > /etc/ld.so.preload

## rebuild frankenphp
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS

WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin go install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
	setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
	cp Caddyfile /etc/caddy/Caddyfile && \
	frankenphp version

from frankenphp.

dunglas avatar dunglas commented on September 12, 2024

That's surprising that you need a full rebuild.

Could you try if cleaning the ldconfig cache works instead?

rm /etc/ld.so.cache
ldconfig

from frankenphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.