GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TOADFARM::MANUAL::BEHINDREVERSEPROXY (3)

.ds Aq ’

NAME

Toadfarm::Manual::BehindReverseProxy - Toadfarm behind nginx

CONTENTS

DESCRIPTION

This is useful when you want to run Toadfarm behind a reverse proxy, such as nginx.

    Nginx config

The rewrite rule is very important, since it will remove the /myapp part from the request URL that the Mojolicious route dispatcher will see.



  upstream myapp {
    server 10.11.12.13:8001;
  }

  server {
    listen 80;
    server_name domain.com

    location /myapp {
      rewrite ^/myapp/?(.*)$ /$1 break;
      proxy_set_header X-Request-Base http://$host/myapp;
      proxy_pass http://myapp;
    }
  }



    Toadfarm script

The magic part here is the X-Request-Base HTTP header which is set by nginx. In addition, you need to set proxy to 1 so Mojo::Server::Daemon can behave correctly.



  #!/usr/bin/perl
  use Toadfarm -init;

  mount "/home/www/project1/script/app1" => {
    "X-Request-Base" => "http://domain.com/myapp",
  };

  start [ "http://*:8080" ], proxy => 1, workers => 8;



SEE ALSO

<http://wiki.nginx.org/HttpProxyModule>

<http://wiki.nginx.org/HttpUpstreamModule>

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TOADFARM::MANUAL::BEHINDREVERSEPROXY (3) 2015-10-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.