読者です 読者をやめる 読者になる 読者になる

kopug memo

名古屋で働くとあるWebエンジニアの覚書。

Catalyst を Reverse Proxy の後ろに置く場合

Perl
perldoc Catalyst

PROXY SUPPORT
Many production servers operate using the common double-server approach, with a
lightweight frontend web server passing requests to a larger backend server. An
application running on the backend server must deal with two problems: the remote
user always appears to be 127.0.0.1 and the server’s hostname will appear to be
"localhost" regardless of the virtual host that the user connected through.

Catalyst will automatically detect this situation when you are running the frontend
and backend servers on the same machine. The following changes are made to the
request.

$c->req->address is set to the user’s real IP address, as read from
the HTTP X-Forwarded-For header.

The host value for $c->req->base and $c->req->uri is set to the real
host, as read from the HTTP X-Forwarded-Host header.

Obviously, your web server must support these headers for this to work.

In a more complex server farm environment where you may have your frontend proxy
server(s) on different machines, you will need to set a configuration option to
tell Catalyst to read the proxied data from the headers.

MyApp->config->{using_frontend_proxy} = 1;

If you do not wish to use the proxy support at all, you may set:

MyApp->config->{ignore_frontend_proxy} = 1;

orz..

試してみよう。