Dance floor Templates, Routes and Keywords Customizing your application Download/Upload Security and Error Handling Deployment Conclusion and Future

Dancer Academy - From Zero to Hero

Stefan Hornburg (Racke) [email protected]

eCommerce Innovation 2013, Hancock, 8th October 2013

racke Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

American Spaces Applications

I Dashboard https://americanspaces.state.gov

I eLibraryUSA http://elibraryusa.state.gov

I eShop https://eshop.state.gov

I LDAP administration

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Easy to start with

I Application ready to go

I Syntax easy to understand

I Routes and Keywords

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Easy to expand

I Plugins

I Hooks

I Engines

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Quickstart I

I cpanm Dancer

I cpanm YAML

I dancer -a Dropbox

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Program

./bin/app.pl

#!/usr/bin/env use Dancer ; use Dropbox ; dance ;

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Module

lib/Dropbox.pm

package Dropbox ; use Dancer ’:syntax ’;

our $VERSION = ’ 0.1 ’ ;

get ’ / ’ => sub { template ’index’; };

t r u e ;

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Configuration Files

c o n f i g . yml environments /development.yml environments/ production .yml

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Static Files

css/style.css css/error.css images/ perldancer−bg . jpg images/perldancer.jpg /jquery.js 500. html 404. html favicon.ico dispatch.cgi

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Template

views / index . t t views/layouts/main. tt

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future

Quickstart II

I cd Dropbox

I ./bin/app.pl

I x-www-browser http://localhost:3000/

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Templates

Layout views/layouts/main.tt

Content views/index.tt

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Templates

I Normal Layout

template ’index’, {name => ’Test’}

I Specific Layout

template ’index’, {name => ’Test’}, {layout => ’test’}

I No Layout

template ’index’, {name => ’Test’}, {layout => undef }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Template for Filebrowser

<% directory %>

<% FOREACH f i l e IN f i l e s %> <% END %>

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Route for Filebrowser

get ’/home’ => sub { my $files = autoindex(’/ ’);

template ’filebrowser ’, {directory => ’Home’, files => $files , }; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Configuration

Standard config.yml:

# template engine # simple: default and very basic template engine template: "simple"

Dropbox config.yml:

template: "template_toolkit"

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Routes and Keywords

I HTTP method

I get I post I ... I any

I Path

I Subroutine

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Routes

I String

I Named parameters I Wildcards

I Splat I Megasplat

I Regular expression

I Regular expression with captures

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

String

get ’/home’ => sub { my $files = autoindex(’/ ’);

template ’filebrowser ’, {directory => ’Home’, files => $files , }; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Named parameters

get ’/home/: file ’ => sub { my $files = autoindex(param( ’file ’));

template ’filebrowser ’, {directory => param(’file ’), files => $files , }; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Splat

get ’/images/covers/ ∗ . jpg ’ => sub { my ($isbn) = splat;

i f (− f "public/images/covers/$isbn.jpg") { return send_file "images/covers/$isbn.jpg"; }

status ’not_found’; forward 404; }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Megasplat

https :// eshop. state .gov/ lostpwd / biz@linuxia .de/e642bd543b9907bd2c06aa485261cb1a849a9f23fc7324bff45ebd35f4efe2cb

get ’/lostpwd/∗∗ ’ => sub { my ($email, $hash) = splat;

−>fill (email => $email, hash => $hash);

template( ’lostpwd_confirm ’ , form => $form); }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Regular Expression

Catch-All (last route!)

any qr { . ∗ } => sub { ... };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Regular Expression with Captures

https ://dropbox.nite.si/~racke/talks/dancer−beamer . pdf

any qr{^/~(?[^/]+)/(?. ∗ ? ) / ? $ } => sub { my ($capts, $user, $file);

$capts = captures; $file = $capts −>{ f i l e } ; $user = $capts −>{user } ;

... };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future

Keywords

I get, post, any, put, del, ...

I request, params, param

I redirect, forward, status, header

I config, var, session

I from_json, to_json, from_xml, to_xml

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future var(s) and session

Storing and retrieving data for the current request:

var bar => ’pivo’; $bar = var ’bar’; $bar = vars −>{bar } ;

Storing and retrieving data from the session:

session username => ’[email protected]’;

i f (! session( ’username’)) { redirect uri_for(’/login’); }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Customizing your application

I Engines

I Hooks

I Plugins

I Middleware

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Engines

I Templates

I Sessions

I Logs

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Template Engines

I Dancer::Template::Toolkit

I Dancer::Template::Xslate

I Dancer::Template::TemplateFlute

I ... dozens more

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Configuration

template: "template_flute"

engines : template_flute: f i l t e r s : date : options : format : "%m/%d/%Y" s t r i c t : empty : 0

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Session Engines

Dancer::Session::YAML File based, development only Dancer::Session::Storable File based Dancer::Session::DBI Dancer::Session::Memcached Dancer::Session::MongoDB Dancer::Session::Cookie Session data stored encrypted in a cookie.

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Sessions: Storable

I Engine session: Storable

I Directory session_dir: /var/run/dancer-sessions

I Expiration session_expires: 8 hours

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Sessions: Cookie

I Engine session: Cookie

I Key session_cookie_key: kjsdf07234hjf0sdkflj12*&(@*jk

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Logger Engines

Dancer::Logger::Console Dancer::Logger::File File in logs/ directory, e.g. logs/production.log Dancer::Logger::Syslog Dancer::Logger::Log4perl

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Logger Configuration

I Engine logger: file

I Directory log_path: log

I File log_file: error.log

I Format logger_format: "%t [%P] %L @%D> %m in %f l. %l"

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Hooks

I What is a hook?

I before hook

I before_template_render hook

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

What is a Hook

I Events inside core and plugins

I Hook into the path of execution

I Subroutines in your application

I Multiple hook routines

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future before Hook

Password protected site:

hook ’before’ => sub { unless (session( ’user ’) | | request −>path eq ’/login’ | | request −>path =~ m%^/lostpwd% ){ redirect ’/login’; } };

Files in public aren’t protected!

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future before_template_render Hook

I template ’index’, {message => ’Hello’}

I add default tokens (params, vars, session)

I before_template_render hook

I rendering

I after_template_render hook

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future before_template_render Hook

hook before_template_render => sub { my $tokens = s h i f t ; my $menu ;

i f (session( ’user’)) { $menu = [{name => ’Logout’, url => ’/logout’}]; } else { $menu = [{name => ’Login’, url => ’/login’}]; }

$tokens −>{menu} = $menu ; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Plugins

I Features

I Keywords

I Routes

I Configuration

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Plugins on CPAN

I Count: more than 100

I Overview https://metacpan.org/module/Dancer::Plugins

I Search https://metacpan.org/search?q=dancer+plugin

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Plugins on CPAN

I Dancer::Plugin::Database database

I Dancer::Plugin::Email email

I Dancer::Plugin::Auth::Extensible require_login,require_role,... /login, /login-denied/

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Database Example

my $user = database−>quick_select( ’users ’ , {username => params−>{’username ’ }});

i f ( $user ) { session user => params−>{’username ’ }; }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Database Configuration

plugins : Database : d r i v e r : Pg database: dropbox username: vienna password: nevairbe

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

More SQL Plugins

I Dancer::Plugin::DBIC

I Dancer::Plugin::SimpleCRUD

I ...

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Email Example

$message = template( ’lostpwd_email ’ , {password => $password, url => $url}, { l a y o u t => undef });

email ({type => ’html’, from => ’[email protected]’, to => param( ’email’), subject => ’Forgot password’, message => $message});

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Email Redirect

I Module: Email::Sender::Transport::Redirect

I Configuration:

plugins : Email : t r a n s p o r t : Sendmail : redirect_address: [email protected]

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Auth::Extensible require_login

get ’ / home/∗∗ ’ => require_login sub { ... };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Auth::Extensible require_role

get ’/accounts’ => require_role Administrator sub { template ’accounts’, ... };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Dancer::Plugin::Auth::Extensible Providers

I Config

I Unix

I Database

I LDAP

I Subclass D::P::Auth::Extensible::Provider::Base

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Write Your Own Plugin

package Dancer :: Plugin ::SSO;

use Dancer:: Plugin;

register sso_generate_token => sub { ... };

register_plugin;

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Hooks in Your Own Plugin

Plugin:

register_hook qw/sso_login sso_failure /;

Application:

hook sso_login => sub { my $user_ref = s h i f t ;

session user => $user_ref −>username ; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Middleware Example

#!/usr/bin/env perl

use Dancer ; use Dropbox ; use :: Builder;

my $app = sub { my $env = s h i f t ; my $request = Dancer::Request−>new(env => $env); Dancer−>dance($request ); };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Middleware Example

b u i l d e r { enable SizeLimit => ( max_unshared_size_in_kb => 102400, # 100 Mb check_every_n_requests => 10, );

$app ; };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload Plugins Security and Error Handling Middleware Deployment Conclusion and Future

Middleware in Configuration

plack_middlewares : − − S i z e L i m i t − max_unshared_size_in_kb − 102400

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Download Customizing your application Upload Object Download/Upload Upload HTML Form Security and Error Handling Upload Route Deployment Conclusion and Future

Download/Upload

I File download

I Upload object

I Upload form + code

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Download Customizing your application Upload Object Download/Upload Upload HTML Form Security and Error Handling Upload Route Deployment Conclusion and Future

File Download

get ’ / home/∗∗ ’ => sub { my ($parts) = splat; my $path_relative = join (’/ ’, @$parts); my $path = autoindex_file_path($path_relative );

i f (− f $path ) { return send_file $path, system_path => 1; } e l s i f (−d $path ) { return template ’filebrowser ’, {directory => pop( @$parts ) , files => autoindex($path_relative )}; } };

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Download Customizing your application Upload Object Download/Upload Upload HTML Form Security and Error Handling Upload Route Deployment Conclusion and Future

Upload Object

upload( ’upload_file ’) => Dancer::Request::Upload

filename Filename sent by user basename Stripped filename size Size in bytes type Content type content File content copy_to Copies temporary file

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Download Customizing your application Upload Object Download/Upload Upload HTML Form Security and Error Handling Upload Route Deployment Conclusion and Future

Upload HTML-Form

Upload file


racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Download Customizing your application Upload Object Download/Upload Upload HTML Form Security and Error Handling Upload Route Deployment Conclusion and Future

Upload Route

post ’/home/∗∗ ’ => sub { my ($parts) = splat; my $path_relative = join (’/ ’, @$parts); my $path = autoindex_file_path($path_relative );

i f ($upload_file = upload( ’upload_file ’)) { # upload file to directory my $target_file = join (’/ ’, $path, $upload_file −>basename ) ;

unless ($upload_file −>copy_to($target_file)) { die ’Upload failed ’; } }

redirect "/home/$path_relative"; }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Security Concerns Download/Upload Error Handling Security and Error Handling Deployment Conclusion and Future

Security Concerns

I Input sanitization

I Path traversal

I XSS

I Database injection (SQL/LDAP)

I POST request limits

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Security Concerns Download/Upload Error Handling Security and Error Handling Deployment Conclusion and Future

Path traversal

Example:

https ://dropbox.nite.si/dropbox/[email protected]/../../../../ etc/passwd

Protection:

i f ( grep $_ eq ’..’, @path) { return s t a t u s 403; }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Security Concerns Download/Upload Error Handling Security and Error Handling Deployment Conclusion and Future

Error Handling: 500

I Static File: public/500.html

I Template: error_template

I Stacktrace: show_errors

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Security Concerns Download/Upload Error Handling Security and Error Handling Deployment Conclusion and Future

Error Handling: 404

I Static File: public/404.html

I any qr { . ∗ } => sub { status ’not_found’; template ’my_404’, { path => request −>path } ; };

I Prevent XSS attacks

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Deployment

I Scenarios

I Starman

I Nginx

I Scripts

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Scenarios

I Standalone ./bin/app.pl

I CGI, FastCGI I plackup

I Starman I Twiggy I Corona

I Reverse Proxy

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Scenarios: Reverse Proxy

I Server

I Apache I nginx I

I Dancer Configuration behind_proxy: 1

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future plackup and Starman

I Command line

plackup −E production −s Starman \ −−workers=5 \ −−pid /home/racke/Dropbox/run/Dropbox.pid \ −p 5000 \ −a bin/app.pl \ −D

I Init script

I Daemon::Control

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Nginx Configuration

server { l i s t e n 80; server_name elibraryusa.state.gov; root /home/dancer/Elib/public;

... }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Nginx Configuration

server { ...

l o c a t i o n / { try_files $uri @proxy; access_log off; expires max; }

... }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Nginx Configuration

server { ...

location @proxy { proxy_set_header Host $http_host; proxy_set_header X−Forwarded−Host $host ; proxy_set_header X−Real−IP $remote_addr; proxy_set_header X−Forwarded−For $proxy_add_x_forwarded_for; proxy_pass http://localhost:5001; } }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Nginx Configuration SSL

server { l i s t e n 213.129.249.66:443; server_name eshop. state .gov; root /home/interch/eShop/public;

s s l on ; ssl_certificate_key /etc/ssl/private/eshop.state.gov.key; ssl_certificate /etc/ssl/certs/eshop.state.gov.pem;

... }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Nginx Configuration SSL

server { ...

location @proxy { proxy_set_header Host $http_host; proxy_set_header X−Forwarded−Host $host ; proxy_set_header X−Real−IP $remote_addr; proxy_set_header X−Forwarded−For $proxy_add_x_forwarded_for; proxy_set_header X−Forwarded−Proto https; proxy_pass http://localhost:5001; } }

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Scenarios Customizing your application Starman Download/Upload Nginx Security and Error Handling Scripts Deployment Conclusion and Future

Scripts

use Dancer ’:script ’;

set logger => ’console’; set logger_format => ’%m’;

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Dancer Problems Download/Upload Dancer2 Security and Error Handling Community Deployment Conclusion and Future

Dancer Problems

I Merging configuration files

I prefix is global

I Session key deletion session user => undef

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Dancer Problems Download/Upload Dancer2 Security and Error Handling Community Deployment Conclusion and Future

Dancer2

I Pure OO (Moo)

I Globals

I Scoping for Subapplications

I YAML => Config::Any

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Dancer Problems Download/Upload Dancer2 Security and Error Handling Community Deployment Conclusion and Future

Community

Web: http://perldancer.org/ Github: git://github.com/PerlDancer/Dancer.git git://github.com/PerlDancer/Dancer2.git Dropbox plugin: https: //metacpan.org/module/Dancer::Plugin::Dropbox IRC: #dancer @ irc.perl.org Contribution: Dancer::Development

racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Dancer Problems Download/Upload Dancer2 Security and Error Handling Community Deployment Conclusion and Future

The End

Slides: http://www.linuxia.de/talks/eic2013/ dancer-beamer.pdf

racke Dancer Academy - From Zero to Hero

NameTypeModified
<% file .name %> <% file .type %> <% file .modified %>