Comments (8)
Also with path info, this line try_files $uri =404;
on top of php_fastcgi.conf
does not work because $uri
may not point to a real path.
from nginxconfig.io.
Alternatively to check the existence of the file
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
from nginxconfig.io.
Also this line is required in php_fastcgi.conf
fastcgi_param PATH_INFO $fastcgi_path_info;
from nginxconfig.io.
It works perfectly fine for me.
(Maybe you've skipped the index.php fallback?)
If you check the major PHP frameworks' nginx documentation:
- https://laravel.com/docs/5.7/deployment#nginx
- https://symfony.com/doc/current/setup/web_server_configuration.html#nginx
- https://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config#nginx
You will see only the fastcgi_split_path_info ^(.+\.php)(/.*)$;
is required, everything else is defined in the stock fastcgi_params
file.
try_files $uri =404;
is needed for handling a non existing php file with nginx 404 error page rather than PHP-FPM's No input file specified.
message.
Also If Is Evil, nginxconfig.io does not use any if
in configurations.
from nginxconfig.io.
Now I understand your issue with try_files
.
I was preparing the Magento support and there is the following URL structure for setup: /setup/index.php/navigation
.
The try_files
failed, so I've moved it from php_fastcgi.conf
to location ~ \.php$ {}
, so it can be overridden.
from nginxconfig.io.
Hmm I don't know, it seems to me that this regex \.php$
will not match e.g. /index.php/some/path/info
, will it?
By the way, I encountered the problem when installing moodle.
As for the frameworks documentation, it does not uses path info, the route is passed as a query string as you can see in this line try_files $uri $uri/ /index.php?$query_string
. Older PHP applications still uses index.php
in the URL, which is why the part after \.php
still need to be matched to support path info in the URL.
from nginxconfig.io.
Example from nginx website:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include the fastcgi_param setting
include fastcgi_params;
# SCRIPT_FILENAME parameter is used for PHP FPM determining
# the script name. If it is not set in fastcgi_params file,
# i.e. /etc/nginx/fastcgi_params or in the parent contexts,
# please comment off following line:
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
from nginxconfig.io.
Thanks for your inputs @char101!
I've made a lot of research in this topic and commited (c25228e) the Legacy PHP routing
option.
It utilises the fastcgi_split_path_info
directive and PATH_INFO
param only if enabled.
Also made a PR to Laravel docs in this topic: laravel/docs#4847
from nginxconfig.io.
Related Issues (20)
- Unable to redirect http to https . Can anyone help here ? HOT 1
- Website Domain Redirection and WordPress Ecommerce Plan Purchase Error HOT 1
- Wider content and sticky or similiar right column behavior on side by side mode HOT 1
- Getting `"[emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in webiste.conf` HOT 4
- [FR] Add support for `proxy_cookie_domain`
- Wordpress config is generated for every domain
- Spam.
- support client certificates HOT 1
- Restrict access via IP and only allow access via a domain name
- Add prettier
- Nginx 1.25.1+ [warn] the "listen ... http2" directive is deprecated
- Binary Packages Now Available for the Preview NGINX QUIC+HTTP/3 Implementation
- Use proper ESM imports w/ extensions
- Why not remove X-XSS-Protection?
- nginx 1.25.1: the deprecated "ssl" directive is not supported anymore
- Spam
- Change default Referrer-Policy HOT 1
- Disable caching when using a reverse proxy
- Spam
- Expect to add NJet configuration generation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nginxconfig.io.