Last active
November 16, 2023 13:30
-
-
Save danielpotthast/b33244144cbb934830c69f1fa8de984e to your computer and use it in GitHub Desktop.
NGINX – Snippet: FastCGI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; | |
# regex to split $uri to $fastcgi_script_name and $fastcgi_path | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# Bypass the fact that try_files resets $fastcgi_path_info | |
# see: http://trac.nginx.org/nginx/ticket/321 | |
set $path_info $fastcgi_path_info; | |
fastcgi_param PATH_INFO $path_info; | |
fastcgi_buffers 8 16k; | |
fastcgi_buffer_size 32k; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
set $param_https off; | |
set $param_port 80; | |
if ($scheme = https) { | |
set $param_https on; | |
set $param_port 443; | |
} | |
if ($server_port = 443) { | |
set $param_https on; | |
set $param_port 443; | |
} | |
if ($server_port = 8443) { | |
set $param_https on; | |
set $param_port 443; | |
} | |
if ($http_x_forwarded_proto = "https") { | |
set $param_https on; | |
set $param_port 443; | |
} | |
fastcgi_param HTTPS $param_https; | |
fastcgi_param SERVER_PORT $param_port; | |
# keep connection | |
fastcgi_keep_conn on; | |
fastcgi_index index.php; | |
include fastcgi.conf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment