perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
855 stars 246 forks source link

Simplesamlphp in subfolder #232

Open heyyoyo opened 8 years ago

heyyoyo commented 8 years ago

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, 
jygastaud commented 8 years ago

Hi,

We solved that issue some months ago following that process.

.
├── docroot
│   ├── // Drupal core files
└── simplesamlphp
    └── www

Note that we symlink www directory of simplesamlphp inside drupal 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;
    }
}
server {
    listen 80; # IPv4

    ## HERE IS
    ## PERUSIO CONFIG

    ## Including simple SAML PHP, for authentication
    include simplesamlphp.conf;
} # HTTP server

Hope that helps.

heyyoyo commented 8 years ago

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"

heyyoyo commented 8 years ago

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.

jygastaud commented 8 years ago

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.

abdalrhman-alhomsi commented 8 years ago

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?

olilolo commented 7 years ago

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

drupal-8.txt

I use same simplesamlphp.conf file as indicated bjygastaud

huwiler commented 5 years ago

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).

huwiler commented 5 years ago

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;
    }
}