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

mastercontainer - limit access to php-fpm to localhost #3317

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

szaimen
Copy link
Collaborator

@szaimen szaimen commented Sep 7, 2023

address part of #3172

Signed-off-by: Simon L <szaimen@e.mail.de>
@szaimen szaimen added 3. to review Waiting for reviews enhancement New feature or request labels Sep 7, 2023
@szaimen szaimen added this to the next milestone Sep 7, 2023
Comment on lines +59 to +60
grep -q ';listen.allowed_clients' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|;listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1|' /usr/local/etc/php-fpm.d/www.conf; \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grep -q ';listen.allowed_clients' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|;listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1|' /usr/local/etc/php-fpm.d/www.conf; \
grep -q 'listen =' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|listen =.*|listen = /var/run/php.sock|' /usr/local/etc/php-fpm.d/www.conf; \

And change the Apache PHP handler to: SetHandler "proxy:unix:/var/run/php.sock"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right, lets do it like this then

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/docker-library/php/blob/e9e47fd185d6b36e491c713811437b0c17944faa/8.2/alpine3.18/fpm/Dockerfile#L249

Suggested change
grep -q ';listen.allowed_clients' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|;listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1|' /usr/local/etc/php-fpm.d/www.conf; \
grep -q 'listen =' /usr/local/etc/php-fpm.d/www.conf; \
sed -i 's|listen =.*|;listen = /var/run/php.sock # handled in zz-docker.conf|' /usr/local/etc/php-fpm.d/www.conf; \
grep -q 'listen =' /usr/local/etc/php-fpm.d/zz-docker.conf; \
sed -i 's|listen =.*|listen = /var/run/php.sock|' /usr/local/etc/php-fpm.d/zz-docker.conf; \

And change the Apache PHP handler to: SetHandler "proxy:unix:/var/run/php.sock"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

healthcheck also needs to check if /var/run/php.sock exists

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we just actually limit it to 127.0.0.1:::1? would that be fine for you? Sounds like the easier approach...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see but perfomance is not critical for the mastercontainer... So I would honestly prefer an easier setup which in this case is limiting to localhost... Wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why it is simpler to limit ips, instead of using a socket

Copy link
Collaborator Author

@szaimen szaimen Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 lines of code vs 4? also we need to adjust the healthcheck but yeah if you really want we can also use a socket

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the socket

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zoey2936 lets switch to the socket in a follow-up.

I would welcome a PR :)

@Zoey2936
Copy link
Collaborator

Zoey2936 commented Sep 7, 2023

also not needed, since php fpm is by default only exposed to 127.0.0.1 if I remember correctly

@Zoey2936
Copy link
Collaborator

Zoey2936 commented Sep 7, 2023

/var/www/html # cat /usr/local/etc/php-fpm.d/www.conf | grep listen | grep -v ";"
listen = 127.0.0.1:9000

@szaimen
Copy link
Collaborator Author

szaimen commented Sep 8, 2023

/var/www/html # cat /usr/local/etc/php-fpm.d/www.conf | grep listen | grep -v ";"
listen = 127.0.0.1:9000

It is the same in the nextcloud container and there access from a different container is obiously possible so switching to a socket in the mastercontainer probably makes sense...

@szaimen szaimen merged commit 8b0b0d0 into main Sep 12, 2023
3 checks passed
@szaimen szaimen deleted the enh/noid/limit-mastercontainer-to-localhost branch September 12, 2023 09:05
@szaimen
Copy link
Collaborator Author

szaimen commented Sep 13, 2023

This is now released with v7.2.0 Beta. Testing and feedback is welcome! See https://github.com/nextcloud/all-in-one#how-to-switch-the-channel

Zoey2936 added a commit that referenced this pull request Sep 16, 2023
Signed-off-by: Zoey <zoey@z0ey.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants