Welcome! Log In Create A New Profile

Advanced

Re: Аналог ProxyPassReverse

November 04, 2015 02:14PM
т.е. надо делать как то так?

server {
listen 80;
server_name www.example.net http://imagesclr.example.net;

location ~ \.jsp$ {
proxy_pass http://javaclr.example.net:8080;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect http://javaclr.example.net:8080/ /;
}

location ~ \.asp$ {
proxy_pass http://aspclr.example.net http://javaclr.example.net
:8080;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect http://aspclr.example.net
http://javaclr.example.net:8080/
/;
}

location ~ \.(png|jpg|js|css)$ {
proxy_pass http://s3aws.example.net http://javaclr.example.net;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect http://s3aws.example.net http://javaclr.example.net/
/;
}
}

Из того что я понял apache лишь выполняет роль обычного reverse proxy,
просто вся логика у него реализована через .htaccess. например там есть
такие строки

RewriteRule (.*)\.(jsp|do)$ http://javaclr.example.net/$1.$2 [QSA,P]

RewriteRule (.*)\.asp$ http://aspclr.example.net/$1.asp [P]

RewriteRule ^(applet) http://javaclr.example.net/$1 [P]

RewriteRule
(.*)\.(jpg|gif|png|js|css|html|zip|jar|xml|class|pdf|swf|mp4|ico)$
http://images.example.net.s3-website-us-west-2.amazonaws.com/$1.$2 [NC,P]

ну и т.д.



2015-11-04 13:46 GMT+02:00 Igor Sysoev <igor@sysoev.ru>:

> On 04 Nov 2015, at 13:45, Alex Domoradov <alex.hha@gmail.com> wrote:
>
> Столкнулся с проблемой необходимости перевести apache на nginx. На данный
> момент в apache в настройках виртуалхоста есть директивы
>
> ProxyPassReverse / http://javaclr.example.net/
> ProxyPassReverse / http://imagesclr.example.net/
> ProxyPassReverse / http://aspclr.example.net/
> ProxyPassReverse / http://vsclr.example.net/
>
> В офф документации nginx -
> https://www.nginx.com/resources/wiki/start/topics/examples/likeapache/
> говорится, что достаточно использовать proxy_pass и передавать соотв хедеры.
>
> Но тут возникает вопрос, а как мне в одном location использовать несколько
> директив proxy_pass. Или единственный выход использовать map, что то вида
>
> map $host $proxy_host {
> default "";
> "~(javaclr|imagesclr|aspclr|vsclr)\.example\.net" "$host";
> }
>
> server {
> listen 80;
> server_name javaclr.example.net imagesclr.example.net
> aspclr.example.net vsclr.example.net;
>
> location / {
> proxy_pass http://$proxy_host;
> proxy_set_header X-Forwarded-Host $host;
> proxy_set_header X-Forwarded-Server $host;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> }
> }
>
>
> Аналог ProxyPassReverse - proxy_redirect:
> http://nginx.org/ru/docs/http/ngx_http_proxy_module.html#proxy_redirect
> Но, возможно, правильнее не валить всё в одну кучу, а сделать несколько
> серверов.
>
>
> --
> Igor Sysoev
> http://nginx.com
>
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

Аналог ProxyPassReverse

ALex_hha November 04, 2015 05:46AM

Re: Аналог ProxyPassReverse

Igor Sysoev November 04, 2015 06:48AM

Re: Аналог ProxyPassReverse

ALex_hha November 04, 2015 02:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 134
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready