Having issues setting up simplesamlphp with nginx

2,196 views
Skip to first unread message

jde...@gmail.com

unread,
Feb 13, 2017, 8:48:14 AM2/13/17
to SimpleSAMLphp
My original issue was posted here: https://github.com/simplesamlphp/simplesamlphp/issues/560

I am trying to run simplesamlphp on nginx (config file listed below) but when I try loading the page, it redirects me here http://simplesamlphp.test/simplesaml/module.php/core/frontpage_welcome.php and says file not found. What is the issue here?

I have downloaded simplesamlphp via composer to a web project of my own (as its a dependency) and have symlinked the folder in the vendor folder to /var/www/simplesamlphp. However, I even tried it without symlinking and hit the same roadblock.


server {
listen 80;
server_name simplesamlphp.test;
error_log /var/log/nginx/error.log info;
root /var/www/simplesamlphp/simplesamlphp/www;
index index.php index.html index.htm;
location / {
# Don't touch PHP for static content.
try_files $uri /index.php?$query_string;
}
location /simplesaml {
alias /var/www/simplesamlphp/simplsamlphp/www;
index index.php;
location ~ .php$ {
fastcgi_split_path_info ^(.+?.php)(|/.)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
fastcgi_read_timeout 60;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
# Use fastcgi for all php files.
location ~ .php$ {
fastcgi_split_path_info ^(.+?.php)(|/.
)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
fastcgi_read_timeout 60;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}

Peter Schober

unread,
Feb 13, 2017, 5:46:51 PM2/13/17
to SimpleSAMLphp
* jde...@gmail.com <jde...@gmail.com> [2017-02-13 14:48]:
> I am trying to run simplesamlphp on nginx (config file listed below) but
> when I try loading the page, it redirects me here
> http://simplesamlphp.test/simplesaml/module.php/core/frontpage_welcome.php and
> says file not found. What is the issue here?

Have a look at the very old (2014) thread with the subject
"SimpleSAMLphp / Nginx / metatada"
which last week (Feb 8th) got another reply with someone's working
configuration for Nginx.

HTH,
-peter

jde...@gmail.com

unread,
Feb 14, 2017, 12:30:37 PM2/14/17
to SimpleSAMLphp, peter....@univie.ac.at
I ended up getting it to work with these settings:

server {
    listen 80;

    server_name simplesamlphp.test;
    error_log /var/log/nginx/error.log info;
    root /var/www/simplesamlphp/simplesamlphp/www;
    index index.php index.html index.htm;

    location / {
        # Don't touch PHP for static content.
        try_files $uri /index.php?$query_string;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    # Use fastcgi for all php files.
    location ~ \.php$|^/update.php {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_intercept_errors on;
        fastcgi_read_timeout 60;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
    }
    location /simplesaml {
                alias /var/www/simplesamlphp/simplesamlphp/www;
                location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
                        include fastcgi_params;
                        fastcgi_pass 127.0.0.1:9000;

                        fastcgi_split_path_info ^(.+?\.php)(/.+)$;
                        fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
                        fastcgi_param PATH_INFO $pathinfo if_not_empty;
                }

        }

    location @rewrite {
        rewrite ^ /index.php;
    }

    location ~ ^/sites/.*/files/styles/ {
        try_files $uri @rewrite;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ (^|/)\. {
        return 403;
    }

    gzip on;
    gzip_proxied any;
    gzip_static on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;
    gzip_comp_level 6;
    gzip_types
        text/plain
        text/css
        text/xml
        text/javascript
        application/x-javascript
        application/json
        application/xml
        application/xml+rss
        application/xhtml+xml
        application/x-font-ttf
        application/x-font-opentype
        image/svg+xml
        image/x-icon;
    gzip_buffers 16 8k;
    gzip_min_length 512;

Family Okeke

unread,
Jun 30, 2021, 5:07:38 AM6/30/21
to SimpleSAMLphp
HI I am having this same issue on Nginx. What exactly fixed it for you? I notice your root is the exact same path as your alias "/var/www/simplesamlphp/simplesamlphp/www"

I would really appreciate your feedback

THank  you!

Paul Okeke

unread,
Jun 30, 2021, 5:10:53 AM6/30/21
to SimpleSAMLphp
Hi I am having pretty much the same issue. Could you share what specific change to your settings made it work?

On Tuesday, February 14, 2017 at 12:30:37 PM UTC-5 jde...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages