serversideup / docker-php

🐳 Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more!
https://serversideup.net/open-source/docker-php/
GNU General Public License v3.0
1.65k stars 108 forks source link

Allow FastCGI parameters to be set via environment variable #381

Closed jaydrogers closed 2 months ago

jaydrogers commented 2 months ago
          Can these be changed into configurable options? Currently we have to replace them using a sed call in the Docker file

We use InertiaJS and it sends a bunch of extra headers which keep blocking nginx

@jaydrogers

Originally posted by @bretto36 in https://github.com/serversideup/docker-php/issues/305#issuecomment-2148840930

jaydrogers commented 2 months ago

Hey @bretto36,

Could you elaborate more on what issues you're running into? We're running InertiaJS and we haven't had any issues with it.

bretto36 commented 2 months ago

On pages with lots of components the headers that get sent for preloading from laravel/inertia cause an error

We've had to increase the fastcgi size a few times now. Only happens on pages with LOTS of components though.

We also have a large CSP in place which probably adds to the overall header size

bretto36 commented 2 months ago

@jaydrogers This is what we do to fix currently and it's not clean. Because we bad a 502 bad gateway from nginx

FIND fastcgi_buffers 8 8k; and change to fastcgi_buffers 8 128k;

RUN sed -i 's/fastcgi_buffers 8 8k;/fastcgi_buffers 8 128k;/' /etc/nginx/site-opts.d/http.conf.template

FIND fastcgi_buffer_size 8k; and change to fastcgi_buffer_size 128k;

RUN sed -i 's/fastcgi_buffer_size 8k;/fastcgi_buffer_size 128k;/' /etc/nginx/site-opts.d/http.conf.template

This is the header that comes through on inertia requests and on pages where there might be 100 components it's causing the 502 bad gateway Link: https://www.ourprivatewebsite.com/vite/assets/vendor-DOCBipsl.css; rel="preload"; as="style"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/app-BgXWi5CI.css; rel="preload"; as="style"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/AppLayout-Dh72TD9p.css; rel="preload"; as="style"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/DataTable-Ci3Z2Z-m.css; rel="preload"; as="style"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/widgetList-CgCkd_HP.css; rel="preload"; as="style"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/app-BlTBcJuK.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/vendor-BVpJOPMw.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Select-D_6GEM4M.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/AppLayout-8H1WyAIN.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/DataTable-DeU16A_s.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Filter-DBsJIDwS.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/NotificationMessage-DNLmqtQk.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/widgetList-lG-5fs01.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/TertiaryButton-DYif8TcJ.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Dialog-D14z6lDx.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Spinner-9TH_e2Iv.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/InputError-CotbE7uV.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/InputLabel-ZpMvucLD.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/TextInput-DOQHesha.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/PrimaryButton-BnZAyTs2.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Pagination-OldOVRe3.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/PaginationLinks.vue_vue_type_script_setup_true_lang-wynNfNip.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/DialogModal-BFKkD-ZW.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/CondensedDate-v0q26KmN.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/Checkbox-BX9t8MED.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/StringInput-BbQC1S_3.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1", https://www.ourprivatewebsite.com/vite/assets/MultiSelectInput.vue_vue_type_script_setup_true_lang-B7lAWWZ5.js; rel="modulepreload"; nonce="ADWf7CukAPGc269DPxFFLNKfEFaeVQtUnqTzZ3g1"

jaydrogers commented 2 months ago

Thanks for the extra info. Take a look at this if you can help me test:

PR to review

Docs to Review

Preview URL is here: https://381-allow-fastcgi-parameters.serversideup-php.pages.dev/

Image To Test

That PR is being pushed to our development repo. Any image with docker.io/serversideup/php-dev:382-* will be from that PR, but you have to wait until the job finishes (could be an hour from this post)

Job to keep an eye on

The test images will not be available until this job completes: https://github.com/serversideup/docker-php/actions/runs/9572648967

Next Steps

Once the job is completed, please take a look at the docs and make sure they make sense:

image

Also, please test with this new method and let me know if you like this approach 👍