Skip to content

Instantly share code, notes, and snippets.

@Logioniz
Last active November 17, 2021 17:17
Show Gist options
  • Select an option

  • Save Logioniz/5776c0cf2d18992235cf to your computer and use it in GitHub Desktop.

Select an option

Save Logioniz/5776c0cf2d18992235cf to your computer and use it in GitHub Desktop.

Revisions

  1. Logioniz revised this gist Dec 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion redirect.pl
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/perl

    # To run
    # To run need listen two ports: 80, 443
    # sudo morbo 12.pl -l https://*:443?cert%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.crt%26key%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.key%26verify%3D0x00 -l http://*:80
    # go to url in browser http://your_ip/qwe/asd

  2. Logioniz revised this gist Dec 10, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions redirect.pl
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@

    # To run
    # sudo morbo 12.pl -l https://*:443?cert%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.crt%26key%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.key%26verify%3D0x00 -l http://*:80
    # go to url in browser http://your_ip/qwe/asd

    use Mojo::Base -strict;

  3. Logioniz created this gist Dec 10, 2015.
    22 changes: 22 additions & 0 deletions redirect.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/perl

    # To run
    # sudo morbo 12.pl -l https://*:443?cert%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.crt%26key%3D%2Fhome%2Flogioniz%2Fcert%2Fserver.key%26verify%3D0x00 -l http://*:80

    use Mojo::Base -strict;

    use Mojolicious::Lite;

    app->hook(before_dispatch => sub {
    my $c = shift;
    my $request_url = $c->req->url->to_abs;
    if ($request_url->scheme eq 'http') {
    $request_url->scheme('https');
    $c->redirect_to($request_url);
    }
    });

    get '/qwe/asd' => sub { shift->render(text => 'Hello, world') };

    app->start;