Last active
August 29, 2015 14:24
-
-
Save sng2c/b3444121b1f2eefddf3d to your computer and use it in GitHub Desktop.
SCRIPT_NAME 가 더 일반적인듯..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Scalar::Util 'weaken'; | |
hook( before_dispatch => sub { | |
use Data::Dump; | |
my $self = shift; | |
my $uri = $self->req->headers->header('SCRIPT_NAME'); | |
my $base = Mojo::URL->new($uri); | |
dd $self->req->url->path; | |
my $raw_path = $self->req->url->path; | |
say $raw_path; | |
$raw_path =~ s/^$uri//; | |
say $raw_path; | |
# say $raw_path; | |
$self->req->url->path($raw_path); | |
$self->req->url->base($base) if $uri; | |
}); | |
# Upload form in DATA section | |
get '/' => sub { | |
my $c = shift; | |
$c->render('index'); | |
}; | |
# Streaming multipart upload | |
post '/upload' => {text => 'Upload was successful.'}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title>Streaming multipart upload</title></head> | |
<body> | |
%= form_for 'upload' => (enctype => 'multipart/form-data') => begin | |
%= file_field 'example' | |
%= submit_button 'Upload' | |
% end | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /mojo { | |
proxy_pass http://127.0.0.1:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header SCRIPT_NAME /mojo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment