Commit 44de0782 authored by Yadd's avatar Yadd
Browse files

Enable new portal with Nginx (#595)

parent f6d85f50
...@@ -385,7 +385,7 @@ prepare_test_server: ...@@ -385,7 +385,7 @@ prepare_test_server:
SBINDIR=`pwd`/e2e-tests/conf/sbin \ SBINDIR=`pwd`/e2e-tests/conf/sbin \
INITDIR=`pwd`/e2e-tests/conf/init \ INITDIR=`pwd`/e2e-tests/conf/init \
ETCDEFAULTDIR=`pwd`/e2e-tests/conf/def ETCDEFAULTDIR=`pwd`/e2e-tests/conf/def
@cp -f e2e-tests/index.fcgi e2e-tests/conf/index.fcgi @cp -f e2e-tests/index.* e2e-tests/conf/
@cp e2e-tests/lmConf-1.js e2e-tests/lemonldap-ng.ini e2e-tests/env.conf e2e-tests/test-nginx.conf e2e-tests/conf/ @cp e2e-tests/lmConf-1.js e2e-tests/lemonldap-ng.ini e2e-tests/env.conf e2e-tests/test-nginx.conf e2e-tests/conf/
@cp e2e-tests/form.html e2e-tests/conf/site @cp e2e-tests/form.html e2e-tests/conf/site
@perl -i -pe 'BEGIN{$$p=`pwd`;chomp $$p}s#__pwd__#$$p#;s#__port__#$(TESTWEBSERVERPORT)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#;' \ @perl -i -pe 'BEGIN{$$p=`pwd`;chomp $$p}s#__pwd__#$$p#;s#__port__#$(TESTWEBSERVERPORT)#;s#__FASTCGISOCKDIR__#$(FASTCGISOCKDIR)#;' \
...@@ -626,15 +626,15 @@ install_manager_site: install_conf_dir ...@@ -626,15 +626,15 @@ install_manager_site: install_conf_dir
# Clean svn files # Clean svn files
@rm -rf $$(find ${RMANAGERSTATICDIR} $(RMANAGERPSGIDIR) \ @rm -rf $$(find ${RMANAGERSTATICDIR} $(RMANAGERPSGIDIR) \
$(RMANAGERTEMPLATESDIR) $(RCONFDIR) -type d -name .svn) $(RMANAGERTEMPLATESDIR) $(RCONFDIR) -type d -name .svn)
$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME) @$(PERL) -i -pe 's#__MANAGERSTATICDIR__#$(MANAGERRELATIVESTATICDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME) @$(PERL) -i -pe 's#__MANAGERTEMPLATESDIR__#$(MANAGERTEMPLATESDIR)#g' $(RCONFDIR)/$(CONFFILENAME)
install_portal_site: install_conf_dir install_portal_site: install_conf_dir
# Portal install # Portal install
@install -v -d $(RPORTALDIR) $(RPORTALSTATICDIR) \ @install -v -d $(RPORTALDIR) $(RPORTALSTATICDIR) \
$(RPORTALDIR)/skins/ \ $(RPORTALDIR)/skins/ \
$(RCRONDIR) $(RCONFDIR) $(RCRONDIR) $(RCONFDIR)
@cp -pR -f $(SRCPORTALDIR)/site/htdocs/index.fcgi $(RPORTALDIR) @cp -pR -f $(SRCPORTALDIR)/site/htdocs/index.* $(RPORTALDIR)
@cp -pR -f $(SRCPORTALDIR)/site/htdocs/static/* $(RPORTALSTATICDIR) @cp -pR -f $(SRCPORTALDIR)/site/htdocs/static/* $(RPORTALSTATICDIR)
@tar -cf - -C ${SRCPORTALDIR}/site/templates/ $$(ls ${SRCPORTALDIR}/site/templates/) |tar -xf - -C $(RPORTALTEMPLATESDIR) @tar -cf - -C ${SRCPORTALDIR}/site/templates/ $$(ls ${SRCPORTALDIR}/site/templates/) |tar -xf - -C $(RPORTALTEMPLATESDIR)
@for f in `find $(RPORTALTEMPLATEDIR) -type f -name '*.tpl'`; do \ @for f in `find $(RPORTALTEMPLATEDIR) -type f -name '*.tpl'`; do \
......
...@@ -12,6 +12,8 @@ server { ...@@ -12,6 +12,8 @@ server {
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock; fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
fastcgi_param LLTYPE manager; fastcgi_param LLTYPE manager;
fastcgi_param SCRIPT_NAME /manager.psgi; fastcgi_param SCRIPT_NAME /manager.psgi;
fastcgi_split_path_info ^(.*\.psgi)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
} }
location / { location / {
......
...@@ -10,13 +10,14 @@ server { ...@@ -10,13 +10,14 @@ server {
location ~ \.psgi(?:$|/) { location ~ \.psgi(?:$|/) {
include /etc/nginx/fastcgi_params; include /etc/nginx/fastcgi_params;
fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock; fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
fastcgi_param LLTYPE cgi; fastcgi_param LLTYPE psgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
set $sn $request_uri; set $sn $document_uri;
if ($sn ~ "^(.*)\?") { if ($sn ~ "^(.*\.psgi).*") {
set $sn $1; set $sn $1;
} }
fastcgi_param SCRIPT_NAME $sn; fastcgi_param SCRIPT_NAME $sn;
fastcgi_param SCRIPT_FILENAME $document_root$sn;
fastcgi_split_path_info ^(.*\.psgi)(/.+)$; fastcgi_split_path_info ^(.*\.psgi)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
} }
...@@ -29,6 +30,10 @@ server { ...@@ -29,6 +30,10 @@ server {
#add_header Strict-Transport-Security "15768000"; #add_header Strict-Transport-Security "15768000";
} }
location /static/ {
alias __PORTALSTATICDIR__;
}
# SOAP functions for sessions management (disabled by default) # SOAP functions for sessions management (disabled by default)
location /index/adminSessions { location /index/adminSessions {
deny all; deny all;
......
use Lemonldap::NG::Portal::Main;
Lemonldap::NG::Portal::Main->run( {} );
worker_processes auto; worker_processes auto;
pid conf/nginx.pid; pid conf/nginx.pid;
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
events { events {
worker_connections 768; worker_connections 768;
...@@ -15,7 +17,7 @@ http { ...@@ -15,7 +17,7 @@ http {
types_hash_max_size 2048; types_hash_max_size 2048;
include /etc/nginx/mime.types; include /etc/nginx/mime.types;
default_type application/octet-stream; default_type application/octet-stream;
error_log conf/nginx.log info; error_log conf/nginx.log debug;
gzip off; gzip off;
include conf/*nginx.conf; include conf/*nginx.conf;
access_log conf/nginx.log lm_combined; access_log conf/nginx.log lm_combined;
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "llng-fastcgi-server 1" .IX Title "llng-fastcgi-server 1"
.TH llng-fastcgi-server 1 "2017-01-05" "perl v5.24.1" "User Contributed Perl Documentation" .TH llng-fastcgi-server 1 "2017-01-09" "perl v5.24.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l
......
...@@ -5,7 +5,7 @@ use strict; ...@@ -5,7 +5,7 @@ use strict;
use warnings; use warnings;
use POSIX; use POSIX;
use Getopt::Long; use Getopt::Long;
use Lemonldap::NG::Handler::SharedConf; use Lemonldap::NG::Handler::Main::Reload;
our $VERSION = '2.0.0'; our $VERSION = '2.0.0';
...@@ -87,6 +87,14 @@ my %builder = ( ...@@ -87,6 +87,14 @@ my %builder = (
return $_apps{$script}->(@_); return $_apps{$script}->(@_);
}; };
}, },
psgi => sub {
return sub {
my $script = $_[0]->{SCRIPT_FILENAME};
return $_apps{$script}->(@_) if ( $_apps{$script} );
$_apps{$script} = do $script;
return $_apps{$script}->(@_);
}
},
); );
unless ($>) { unless ($>) {
...@@ -104,15 +112,30 @@ my $app = sub { ...@@ -104,15 +112,30 @@ my $app = sub {
}; };
# Hook for customFunctions initialization # Hook for customFunctions initialization
use Lemonldap::NG::Handler::API::PSGI::Server; Lemonldap::NG::Handler::Main::Reload->onReload(
$Lemonldap::NG::Handler::API::mode = 'PSGI::Server'; bless( {}, 'Lemonldap::NG::Handler::FastCGI::Loader' ),
Lemonldap::NG::Handler::SharedConf->init(); 'loadCustomLogins' );
my $server = Plack::Runner->new();
$server->parse_options(
'-s' => $engine,
'-E' => 'deployment',
'--pid' => $pidFile,
'--nproc' => $nproc,
'--socket' => $socket,
'--proc-title' => 'llng-fastcgi-server',
( $foreground ? () : '--daemonize' ),
'--no-default-middleware',
%plackOptions,
);
$server->run($app);
package Lemonldap::NG::Handler::FastCGI::Loader;
# Load configuration and look if custom handlers have been defined # Load configuration and look if custom handlers have been defined
{ sub loadCustomLogins {
$Lemonldap::NG::Handler::API::mode = 'PSGI::Server'; my ( $obj, $conf ) = @_;
my $conf = Lemonldap::NG::Handler::SharedConf->checkConf()
or die "Unable to get configuration";
foreach my $lltype ( keys %{ $conf->{nginxCustomHandlers} // {} } ) { foreach my $lltype ( keys %{ $conf->{nginxCustomHandlers} // {} } ) {
my $v = $conf->{nginxCustomHandlers}->{$lltype}; my $v = $conf->{nginxCustomHandlers}->{$lltype};
if ( $v =~ m#[/\\\.]# ) { if ( $v =~ m#[/\\\.]# ) {
...@@ -131,21 +154,6 @@ Lemonldap::NG::Handler::SharedConf->init(); ...@@ -131,21 +154,6 @@ Lemonldap::NG::Handler::SharedConf->init();
}; };
} }
} }
my $server = Plack::Runner->new();
$server->parse_options(
'-s' => $engine,
'-E' => 'deployment',
'--pid' => $pidFile,
'--nproc' => $nproc,
'--socket' => $socket,
'--proc-title' => 'llng-fastcgi-server',
( $foreground ? () : '--daemonize' ),
'--no-default-middleware',
%plackOptions,
);
$server->run($app);
__END__ __END__
=head1 NAME =head1 NAME
......
use Lemonldap::NG::Portal::Main;
Lemonldap::NG::Portal::Main->run({});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment