Some uWSGI comments

This commit is contained in:
Xavier Guimard 2018-03-22 21:52:00 +01:00
parent 8d08566b43
commit d637cc6d50
7 changed files with 158 additions and 3 deletions

View File

@ -24,9 +24,16 @@ server {
location = /reload {
allow 127.0.0.1;
deny all;
# FastCGI configuration
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
fastcgi_param LLTYPE reload;
# OR TO USE uWSGI
#include /etc/nginx/uwsgi_params;
#uwsgi_pass 127.0.0.1:5000;
#uwsgi_param LLTYPE reload;
}
# Client requests
@ -41,8 +48,13 @@ server {
#location = /status {
# allow 127.0.0.1;
# deny all;
# # FastCGI configuration
# include /etc/nginx/fastcgi_params;
# fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
# fastcgi_param LLTYPE status;
# # OR TO USE uWSGI
# #include /etc/nginx/uwsgi_params;
# #uwsgi_pass 127.0.0.1:5000;
# #uwsgi_param LLTYPE status;
#}
}

View File

@ -8,12 +8,22 @@ server {
}
location ~ \.psgi(?:$|/) {
# FastCGI configuration
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
fastcgi_param LLTYPE psgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.*\.psgi)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
# OU TO USE uWSGI
#include /etc/nginx/uwsgi_params;
#uwsgi_pass 127.0.0.1:5000;
#uwsgi_param LLTYPE psgi;
#uwsgi_param SCRIPT_FILENAME /path/to/portal/manager.psgi;
#uwsgi_param SCRIPT_NAME /manager.psgi;
# Uncomment this if you use https only
#add_header Strict-Transport-Security "15768000";
}

View File

@ -9,6 +9,8 @@ server {
location ~ \.psgi(?:$|/) {
# Note that Content-Security-Policy header is generated by portal itself
# FastCGI configuration
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
fastcgi_param LLTYPE psgi;
@ -21,6 +23,14 @@ server {
# ~/CN=(?<CN>[^/]+) $CN;
#}
#fastcgi_param SSL_CLIENT_S_DN_CN $ssl_client_s_dn_cn
# OU TO USE uWSGI
#include /etc/nginx/uwsgi_params;
#uwsgi_pass 127.0.0.1:5000;
#uwsgi_param LLTYPE psgi;
#uwsgi_param SCRIPT_FILENAME /path/to/portal/index.psgi;
#uwsgi_param SCRIPT_NAME /index.psgi;
}
index index.psgi;

View File

@ -8,17 +8,24 @@ server {
location = /lmauth {
internal;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
# FastCGI configuration
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
# Drop post datas
fastcgi_pass_request_body off;
fastcgi_param CONTENT_LENGTH "";
# Keep original hostname
fastcgi_param HOST $http_host;
# Keep original request (LLNG server will received /llauth)
fastcgi_param X_ORIGINAL_URI $request_uri;
# OU TO USE uWSGI
#include /etc/nginx/uwsgi_params;
#uwsgi_pass 127.0.0.1:5000;
#uwsgi_pass_request_body off;
#uwsgi_param CONTENT_LENGTH "";
#uwsgi_param HOST $http_host;
#uwsgi_param X_ORIGINAL_URI $request_uri;
}
# Client requests

View File

@ -0,0 +1,59 @@
# PSGI app that can replace FastCGI server
#
# To use it with uWSGI, use for example:
#
# $ uwsgi --plugins psgi --socket :5000 --psgi e2e-tests/llng-server.psgi
#
# Set LLNG_DEFAULTCONFFILE if it is not in the right place
#$ENV{LLNG_DEFAULTCONFFILE} = 'e2e-tests/conf/lemonldap-ng.ini';
my %builder = (
handler => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->run( {} );
},
reload => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->reload();
},
status => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->status();
},
manager => sub {
require Lemonldap::NG::Manager;
return Lemonldap::NG::Manager->run( {} );
},
cgi => sub {
require CGI::Emulate::PSGI;
require CGI::Compile;
return sub {
my $script = $_[0]->{SCRIPT_FILENAME};
return $_apps{$script}->(@_) if ( $_apps{$script} );
$_apps{$script} =
CGI::Emulate::PSGI->handler( CGI::Compile->compile($script) );
return $_apps{$script}->(@_);
};
},
psgi => sub {
return sub {
my $script = $_[0]->{SCRIPT_FILENAME};
return $_apps{$script}->(@_) if ( $_apps{$script} );
$_apps{$script} = do $script;
unless ( $_apps{$script} and ref $_apps{$script} ) {
die "Unable to load $_[0]->{SCRIPT_FILENAME}";
}
return $_apps{$script}->(@_);
}
},
);
sub {
my $type = $_[0]->{LLTYPE} || 'handler';
return $_apps{$type}->(@_) if ( defined $_apps{$type} );
if ( defined $builder{$type} ) {
$_apps{$type} = $builder{$type}->();
return $_apps{$type}->(@_);
}
die "Unknown PSGI type $type";
};

View File

@ -0,0 +1,57 @@
$ENV{LLNG_DEFAULTCONFFILE} = 'e2e-tests/conf/lemonldap-ng.ini';
use lib 'lemonldap-ng-common/blib/lib';
use lib 'lemonldap-ng-handler/blib/lib';
use lib 'lemonldap-ng-portal/blib/lib';
use lib 'lemonldap-ng-manager/blib/lib';
my %builder = (
handler => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->run( {} );
},
reload => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->reload();
},
status => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->status();
},
manager => sub {
require Lemonldap::NG::Manager;
return Lemonldap::NG::Manager->run( {} );
},
cgi => sub {
require CGI::Emulate::PSGI;
require CGI::Compile;
return sub {
my $script = $_[0]->{SCRIPT_FILENAME};
return $_apps{$script}->(@_) if ( $_apps{$script} );
$_apps{$script} =
CGI::Emulate::PSGI->handler( CGI::Compile->compile($script) );
return $_apps{$script}->(@_);
};
},
psgi => sub {
return sub {
my $script = $_[0]->{SCRIPT_FILENAME};
return $_apps{$script}->(@_) if ( $_apps{$script} );
$_apps{$script} = do $script;
unless ( $_apps{$script} and ref $_apps{$script} ) {
die "Unable to load $_[0]->{SCRIPT_FILENAME}";
}
return $_apps{$script}->(@_);
}
},
);
sub {
my $type = $_[0]->{LLTYPE} || 'handler';
return $_apps{$type}->(@_) if ( defined $_apps{$type} );
if ( defined $builder{$type} ) {
$_apps{$type} = $builder{$type}->();
return $_apps{$type}->(@_);
}
die "Unknown PSGI type $type";
};