drupal-with-nginx
drupal-with-nginx copied to clipboard
Simplesamlphp in subfolder
I'm trying to install with no luck yet the library simplesamlphp inside my drupal website. http://mywebsite.com/simplesamlphp should be an alias to /var/www/simplesamlphp.
What I did till now: I create a new saml.conf inside apps/saml/saml.conf and included it inside my website.conf just after the inclusion of apps/drupal/drupal.conf. Here is its content :
location ~* /simplesamlphp {
alias /var/www/simplesamlphp/www;
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Images inside the path simplesamlphp, are served correctly. but accessing any php files, or just mywebsite.com/simplesamlphp returns a 404 error.
In nginx error log I could see this error:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,
Hi,
We solved that issue some months ago following that process.
- Our directory tree
.
├── docroot
│ ├── // Drupal core files
└── simplesamlphp
└── www
Note that we symlink www
directory of simplesamlphp inside drupal root directory
- Then for Nginx, create a simplesamlphp.conf inside de nginx root directory
location ^~ /simplesaml {
alias /PATH/TO/simplesamlphp/www;
location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
fastcgi_param PATH_INFO $pathinfo if_not_empty;
}
}
- finally add the following line inside your host configuration (inside sites-available/) right before the end of
server{}
block.
server {
listen 80; # IPv4
## HERE IS
## PERUSIO CONFIG
## Including simple SAML PHP, for authentication
include simplesamlphp.conf;
} # HTTP server
- reload nginx :)
Hope that helps.
Thanks a lot for helping me on this ! I could finally access to simplesaml admin :-) But I still have an issue, some page are looping like "login as administrator" or "Diagnostics on hostname, port and protocol" or "phpinfo"
Found it I was using memcache to handle session but memcache wasn't installed correctly. It was causing the looping. Thanks again for your config. But not sure why you need the symbolic link ? It seems to work without for me.
You're right, symlink is not needed with that configuration. It was a requierement of our hosting provider which not use nginx.
I have edited the original answer.
Thanks for your answer, but i get 403 when i request mywebsite.com/simplesaml/.
I did give www-data the ownership of the simplesamlphp folder, any advice?
I have the same issue with 403 when I request mywebsite.com/simplesaml/ I put www-data as ownership of simplesamlphp folder as Nginx is running See my site config
I use same simplesamlphp.conf file as indicated bjygastaud
I know this is old, but it's definitely still relevant. Thanks @jygastaud for pointing me in the right direction here--you saved me a bunch of time. Works great as a subdirectory of Laravel in a Docker container as well (if you substitute unix socket for container_name:9000).
FYI in case it helps others: For the latest version of SimpleSamlPHP, I had to add an additional SCRIPT_NAME fastcgi param in order for modules to load correctly.
location ^~ /saml {
alias /var/www/saml/www;
location ~ ^(?<prefix>/saml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include fastcgi_params;
fastcgi_pass php_fpm_container:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
fastcgi_param SCRIPT_NAME /saml$phpfile;
fastcgi_param PATH_INFO $pathinfo if_not_empty;
}
}