I have a little problem, the get method passing in the url is not recognized on other routes than the home '/'
example: /test?foo=bar
When I dump $_GET on my home route 'website.domain?foo=bar' I get foo=bar but when I dump $_GET on another route like 'website.domain/test?foo=bar' I get nothing in my $_GET dump, an empty array is returned.
[EDIT] Locally everything works normally, it's on server I have this problem.
security.yaml
security:
enable_authenticator_manager: true
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
# used to reload user from session & other features (e.g. switch_user)
users_in_memory: { memory: null }
my_provider:
entity: {class: App\Entity\User, property: uuid}
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: my_provider
custom_authenticators:
- App\Security\AzureAuthenticator
logout: true
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/connect/azure, role: PUBLIC_ACCESS }
- { path: ^/, roles: ROLE_USER}
.htaccess
# https://docs.microsoft.com/fr-fr/azure/app-service/configure-language-php?pivots=platform-linux#change-site-root
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)
RewriteRule ^(.*)$ /public/$1 [NC,L,QSA]
</IfModule>
php_value upload_max_filesize 100M
php_value memory_limit 300M
AzureController.php
<?php
namespace App\Controller;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class AzureController extends AbstractController
{
/**
* Cette fonction effectue la connexion avec Azure
* Ex: Si vous allez sur cette route, un formulaire microsoft vous demandera de vous connecter
*/
#[Route('/connect/azure', name: 'connect_azure')]
public function connectAction(ClientRegistry $clientRegistry, Request $request)
{
$foo = $request->query->get('foo');
dd($foo);
return $clientRegistry
->getClient('azure')
->redirect([
'openid', 'profile', 'email'
], []);
}
/**
* Cette fonction permet de savoir si l'authentification à réussi
* Ex: Après vous être connecté ci-dessus, vous serez rediriger sur cette route qui vous redirigera à son tour vers la route home
*/
#[Route('/connect/azure/check', name: 'connect_azure_check', schemes:['http'])]
public function connectCheckAction(Request $request, ClientRegistry $clientRegistry)
{
try {
return $this->redirectToRoute('home');
} catch (IdentityProviderException $e) {
return new JsonResponse(array('status' => false, 'message' => "User not found!", 'error' => $e->getMessage()));
}
}
}
nginx.conf
server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot/public;
index index.php index.html index.htm;
server_name example.com www.example.com;
port_in_redirect off;
client_max_body_size 1000M;
location / {
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /index.php;
# Disable .git directory
location ~ /\.git {
deny all;
access_log off;
log_not_found off;
}
# Add locations of phpmyadmin here.
location ~ [^/]\.php(/|$) {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
I can't find any solution on internet, maybe my search is wrong. Do you have any ideas ?
I have found my problem, is the nginx.conf file.
My new Nginx.conf
server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot/public;
index index.php index.html index.htm;
server_name example.com www.example.com;
port_in_redirect off;
client_max_body_size 1000M;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
error_page 404 /index.php;
# Disable .git directory
location ~ /\.git {
deny all;
access_log off;
log_not_found off;
}
# Add locations of phpmyadmin here.
location ~ ^/index\.php(/|$) {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
Related
I need help running Laravel from a subfolder in our dev environment.
Our devs have to clone the main site repo into a folder under their subdomain like so:
https://developer.example.com/branch/ points to /var/www/html/developer/branch/
Examples:
https://dev1.example.com/laravel8/
https://dev2.example.com/ticket-12345/
https://dev3.example.com/some-other-branch/
We currently run a homegrown PHP app that this works just fine with, trying to migrate to Laravel (testing with v8.0) I'm finding all routes are broken unless they contain the subfolder name which is not feasible.
// Doesn't work
Route::get('/', function () {
return view('welcome');
});
// Works
Route::get('/laravel8', function () {
return view('welcome');
});
// Doesn't work
Route::get('/welcome', function () {
return view('welcome');
});
// Works
Route::get('/laravel8/welcome', function () {
return view('welcome');
});
// Legacy route handler (Works)
Route::any('/{path?}', LegacyController::class)->where('path', '.*');
I've tried setting the APP_URL to https://dev1.example.com/branch/ which does nothing.
Our NGINX config rewrites requests like so
https://developer.example.com/branch/ -> https://developer.example.com/branch/public/index.php
server {
server_tokens off;
listen 80;
autoindex off;
server_name dev1.example.com;
root /var/www/html/dev1;
access_log /home/dev1/nginx-access.log;
error_log /home/dev1/nginx-error.log debug;
rewrite_log on;
index index.php index.html;
client_max_body_size 100M;
# Rewrite legacy app URLs
# /branch/control.php/login/ -> /branch/login/
#if ($uri ~* "^/([A-Za-z0-9\-\_]+)/control\.php/(.*)$") {
location ~* ^/([A-Za-z0-9\-\_]+)/control\.php/(.*)$ {
rewrite ^/([A-Za-z0-9\-\_]+)/control\.php/(.*)$ /$1/$2; # Works
}
#include /etc/nginx/includes/dev_laravel.conf;
# Capture the subfolder name to a variable
location ~* ^/(?<appid>[A-Za-z0-9\-\_]+) {
alias /var/www/html/dev1/$appid/public;
try_files $uri $uri/ #rewapp;
# Sometimes only contains /branch/login/ other times contains /branch/public/index.php/login/
location ~* ^/([A-Za-z0-9\-\_]+)/(.*\.php)(/.*) {
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME $2;
fastcgi_param SCRIPT_FILENAME /var/www/html/dev1/$1/public/$2;
fastcgi_param PATH_INFO $3;
keepalive_timeout 0;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffers 4 256k;
fastcgi_buffer_size 256k;
fastcgi_intercept_errors off;
#fastcgi_param SCRIPT_FILENAME $document_root$script;
#fastcgi_param PATH_INFO $path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
include fastcgi_params;
}
# Necessary for static files,
# or may fall to another location with incorrect path
# Add more extensions like PDF if necessary
location ~* ^/([A-Za-z0-9\-\_]+)/(.+\.(jpg|jpeg|gif|css|svg|png|js|map|ico|html|xml|txt|woff|woff2))$ {
alias /var/www/html/dev1/$1/public;
try_files $uri /$2 =404;
}
}
# Rewrite URL for Laravel
# https://www.example.com/branch/login/ -> https://www.example.com/branch/public/index.php/login/
location #rewapp {
#rewrite ^/([A-Za-z0-9\-\_]+)/(?:control\.php/)?(.*)$ /$1/index.php/$2 last; # Try to eliminate control.php (Throws file not found)
rewrite ^/([A-Za-z0-9\-\_]+)/(.*)$ /$1/index.php/$2 last;
}
}
Any help is appreciated.
I use docker (php7.4 and nginx) for running my Symfony 5 application, I implemented Bearer authentication using firebase/php-jwt, and can get a token successfully, but when I try to call the APIs using the token in the header, I get 502 Bad Gateway (See the Error) from nginx.
I am sure that the problem comes from my nginx configs, because when I use Symfony Local Web Server, it works.
nginx configuration:
server {
listen 80;
server_name my.local;
root /home/my/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass my-app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/my_error.log;
access_log /var/log/nginx/my_access.log;
}
I increased the buffer size and solved the problem:
server {
server_name my.local;
root /home/my/public;;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass my-app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
error_log /var/log/nginx/my_error.log;
access_log /var/log/nginx/my_access.log;
}
You will have to bear with me here while I try and explain this the best I can.
I am working with a nginx server that I did not set up, I have very little knowledge of nginx. I have set up a new wordpress website which lives under the following url structure subsubdomain.subdomain.domain.com/website/ it is important that the full wordpress website is functional within the /website/ directory.
I have the site set up and the home page works perfectly when I navigate to subsubdomain.subdomain.domain.com/website/, but when I navigate to a subpage subsubdomain.subdomain.domain.com/website/resources/ the server throws File not found.
From my little knowledge of nginx I think this is a file permissions issue, I have logged into the server and run the following command sudo chmod 777 -R /path/to/website and also done sudo chown www:www -R /path/to/website to try and give full access. Unfortunately this has not worked either.
When checking the website access_log and error_log, they are empty. I then checked the nginx main log file and found the following error:
2018/05/31 04:07:42 [crit] 32426#0: *120 open() "/usr/share/nginx//var/www/sites-running/subsubdomain.subdomain.website.com/logs/nginx.access.log" failed (2: No such file or directory) while logging request, client: **.***.***.***, server: *.subdomain.domain.com, request: "GET /website/resources/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "subsubdomain.subdomain.domain.com", referrer: "http://subsubdomain.subdomain.domain.com/website/"
I'll be honest with you guys, this means nothing to me. All I can see is that it looks like the path to the log file is bad. So I went to my website nginx-vhost.conf file to see how it is defined and I have the following code:
access_log /var/www/sites-running/subsubdomain.subdomain.website.com/logs/nginx.access.log
Which looks all good to me.
So now I am stuck, I have no idea how to fix this so if anyone can make some sense of this and can help me out that would be amazing.
Cheers,
Luke.
UPDATE
I have just run nginx -V and noticed that there is a value called prefix, here is the value:
--prefix=/usr/share/nginx
It looks like this could be my problem but I have no idea what this is, how it is used and do not know the damage i could cause if I change it.
UPDATE
Here is my website nginx-vhost.conf file.
# Nginx configuration for Website
# This is for development purposes
server{
listen 80;
server_name subsubdomain.subdomain.domain.com;
set $site_root "/var/www/sites-available/$host";
set $public_html "$site_root/public_html";
set $logs_dir "$site_root/logs";
set $nginx_root "$site_root/webapps/ROOT";
root $nginx_root;
error_log /var/www/sites-available/subsubdomain.subdomain.domain.com/logs/nginx.error.log;
access_log /var/www/sites-available/subsubdomain.subdomain.domain.com/logs/nginx.access.log main;
index index.php;
#default_type text/html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#add_header 'Access-Control-Allow-Origin' "*";
# ------------------------------------------------------
#
# static resources routing for version control on assets
#
# ------------------------------------------------------
#location ~ ^/static/([^/]+)/(content|resources)/(.*)$ {
# alias $public_html/$2/$3;
#}
#location ~ ^/content/(.*)$ {
# alias $public_html/content/$1;
#}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location /wp-admin {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /wp-admin/index.php?$args;
}
# ----------------------------------------
#
# PHP
#
# ----------------------------------------
location ~ \.php {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param CONTENT_ROOT $public_html/content;
fastcgi_param CONTENT_UPLOAD_DIR $public_html/content;
fastcgi_param LOGS_ROOT $logs_dir;
fastcgi_param app.profile staging;
fastcgi_param APP_MODE staging;
fastcgi_param DB_NAME **********;
fastcgi_param DB_USER **********;
fastcgi_param DB_PASS **********;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Here is my main nginx.conf file
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_names_hash_bucket_size 128;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
client_max_body_size 100m;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
#root /var/www/sites-running/nginx-default;
#index index.html index.htm;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# location / {
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# root html;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# }
#}
}
Thanks to everyone for their help. I have finally managed to figure out what was going wrong. I needed to update my conf file to have a second location statement which looked inside of the /website/ folder.
like so:
location /website/ {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/website/ /website/index.php?$args;
}
Here is my full nginx-vhost.conf file:
# Nginx configuration for Website
# This is for development purposes
server{
listen 80;
server_name subsubdomain.subdomain.domain.com;
set $site_root "/var/www/sites-available/$host";
set $public_html "$site_root/public_html";
set $logs_dir "$site_root/logs";
set $nginx_root "$site_root/webapps/ROOT";
root $nginx_root;
error_log /var/www/sites-available/subsubdomain.subdomain.domain.com/logs/nginx.error.log;
access_log /var/www/sites-available/subsubdomain.subdomain.domain.com/logs/nginx.access.log main;
index index.php;
#default_type text/html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#add_header 'Access-Control-Allow-Origin' "*";
# ------------------------------------------------------
#
# static resources routing for version control on assets
#
# ------------------------------------------------------
#location ~ ^/static/([^/]+)/(content|resources)/(.*)$ {
# alias $public_html/$2/$3;
#}
#location ~ ^/content/(.*)$ {
# alias $public_html/content/$1;
#}
location /website/ {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/website/ /website/index.php?$args;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location /wp-admin {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /wp-admin/index.php?$args;
}
# ----------------------------------------
#
# PHP
#
# ----------------------------------------
location ~ \.php {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param CONTENT_ROOT $public_html/content;
fastcgi_param CONTENT_UPLOAD_DIR $public_html/content;
fastcgi_param LOGS_ROOT $logs_dir;
fastcgi_param app.profile staging;
fastcgi_param APP_MODE staging;
fastcgi_param DB_NAME **********;
fastcgi_param DB_USER **********;;
fastcgi_param DB_PASS **********;;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
I am trying to setup Zurmo CRM on my local machine (Win8x64). After installing all the requirements I want to get started with the actual installation. The problem is that it seems the paths are not correctly passed from NGinx to FastCGI PHP. Here is my Nginx serve configuration:
server {
listen 80;
server_name zurmo.local;
root html/zurmo.local;
set $index "index.php";
charset utf-8;
location / {
index index.html $index;
try_files $uri $uri/ /$index?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /$index;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
location ~ /\.ht {
deny all;
}
}
As a result, when I make a call to zurmo.local (which is added to hosts file) i get "This webpage has a redirect loop" with a URI that looks like this http://zurmo.local/app/app/ [...] /app/app/index.php If instead of $document_root$fsn and I comment the PATH_INFO and PATH_TRANSLATED than I get No input file specified. with a URI that looks like http://zurmo.local/app/app/index.php
Looking further into it, when I have added access_log html/zurmo.local/logs/access.log; the Nginx error.log shows me the following: [timestamp] [emerg] 4064#3660: CreateFile() "[path to stack]\nginx/html/zurmo.local/logs/access.log" failed (3: The system cannot find the path specified). As you can see the directory separator is not consistent.
One last note, my Nginx home directory is situated at nginx/html which is in fact a smlink to of ../home This is purely for keeping my file structure in a way that fits my day to day work.
How can I correctly configure Nginx in order to proceed (with the Zurmo installation) ?
I know this is an old question, but here is what I have done to make nginx + zurmo work.
server {
listen 80;
server_name zurmo.local;
root /home/www/zurmo.local;
access_log /var/log/nginx/zurmo.access.log main;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) { deny all; }
location ~ /\. { deny all; access_log off; log_not_found off; }
location = /favicon.ico { log_not_found off; access_log off; }
location ~ \.(js|css|png|jpg|gif|ico|pdf|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 600s;
fastcgi_send_timeout 600s;
}
}
I don't think you need the if() statement in your *.php block. In my nginx setups that's all i ever needed:
# Process PHP files
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Include the standard fastcgi_params file included with nginx
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
Okay, i setup a debian install with ispconfig3 ,php5-fpm and nginx, the main site, drupal is working fine, even perfect. But i also have a modded phpbb3 board, in a subdir, named 'forum'.
Now for some reason i get the following error from nginx when accesing the dir:
'ERROR 500 - Internal Server Error!'
This is the content of the nginx directiv field(for vhost):
# search for already compressed files
gzip_static on;
gzip on;
# some images have no mime type
default_type image/jpeg;
# 404 generated from php can be rather slow. Uncomment with care
error_page 404 /index.php;
# disallow access to version control directory, but return 404, not to disclose information
location /.git {
return 404;
}
# robots.txt is important for search engines
location /robots.txt {
access_log off;
}
# This is mostly based on Drupal's stock .htaccess
location ~* ^.+(\.(txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
return 404;
}
# serve imagecache files directly or redirect to drupal if they do not exist
location ~* imagecache {
access_log off;
expires 30d;
try_files $uri #drupal;
}
# Drupal 7 image stylef
location ~* image/generate {
access_log off;
expires 30d;
try_files $uri #drupal;
}
# serve static files directly
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|swf|flv)$ {
access_log off;
log_not_found off;
expires 30d;
}
location #rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
break;
}
# This rewrites pages to be sent to PHP processing
location #drupal {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
location / {
try_files $uri #cache;
}
# This will try to see if we have a boost file in place. no harm done if this is not used
location #cache {
# queries, drupal cookies, or not GET methods, all require PHP processing.
if ($query_string ~ ".+") {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID" ) {
return 405;
}
if ($request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
error_page 405 = #drupal;
# Drupal uses 1978 - I am 4 years older than Dries :)
add_header Expires "Tue, 22 Sep 1974 08:00:00 GMT";
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
try_files /cache/normal/$host/${uri}_.html /cache/mobile/$host/${uri}_.html /cache/perm/$host/${uri}_.css /cache/perm/$host/${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html #drupal;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
location /forum {
root /var/www/ashladan.net/web;
index index.php index.html index.htm;
location ~ ^/forum/(.+\.php)$ {
try_files $uri =404;
root /var/www/ashladan.net/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~* ^/forum/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /var/www/ashladan.net/web;
}
}
It may be standard PHP response for uncaught exception / fatal / syntax error with no output.
You can either turn on error logging in php.ini and check your log file, or just at the beginning of your index.php file in this directory add two lines:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
So if it is PHP's fault you will get more details on this error.