June 25, 2013 02:51AM
Мне кажется, что надо писать всетаки так как в первом варианте, только надо учесть что все запросы будут отдаваться в jetty и деректива root теряет смысл

я бы попробовал изменить

> if ($host = "m.domain.ru") {
> set $subdomain "m";
> }

на

if ($host = "m.domain.ru") {
set $subdomain "/m";
}

и

> location / {
> proxy_pass http://127.0.0.1:8080/$subdomain;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_cache off;
> proxy_redirect off;
> }

на

location / {
proxy_pass http://127.0.0.1:8080$subdomain;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_cache off;
proxy_redirect off;
}

также надо не забывать, что указание в proxy_pass $uri, на jetty не будет передаваться оригинальный $uri





point212 Wrote:
-------------------------------------------------------
> Добрый день.
> Не могу добиться от nginx казалось бы простой вещи.
> Есть nginx, и есть jetty за ним.
> Нужно чтобы пользователь заходил на URL m.domain.ru, а jetty думал что
> пришли по URL m.domain.ru/m. При этом в адресной строке пользователя
> /m не отображалось.
>
> Вот текущий конфиг:
>
> nginx.conf
> =====================
>
> ...
>
> server {
> server_name domain.ru *.domain.ru;
> set $subdomain "";
> if ($host = "m.domain.ru") {
> set $subdomain "m";
> }
> root /opt/jetty/webapps/root/WEB-INF/application/;
> location / {
> proxy_pass
> http://127.0.0.1:8080/$subdomain;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_cache off;
> proxy_redirect off;
> }
> }
>
> ...
>
> ========================
>
> Были и другие варианты конфигурации.
> Например вот такой:
> ...
> server {
> server_name ~^(.*)\.domain\.ru$;
> set $subdomain $1;
> root /opt/jetty/webapps/root/WEB-INF/application/;
> location / {
> proxy_pass http://127.0.0.1:8080/$subdomain;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> proxy_set_header Host $host;
> proxy_cache off;
> proxy_redirect off;
> }
> }
> ...
>
> При попытке входа на m.domain.ru выдается ошибка 404, а на domain.ru
> грузится сайт, но без всей статики (подозреваю что это ошибка
> бэкэнда). Не понятно как именно переписывается URL, но явно не так,
> как я ожидаю.
> Как заставить nginx писать в логи всё, что происходит?
> Логгирование настроено вот так:
>
> ...
> error_log /var/log/nginx/error.log info;
>
> http {
> ...
> log_format main '$remote_addr - $remote_user [$time_local]
> "$request" '
> '$status $body_bytes_sent "$http_referer" '
> '"$http_user_agent" "$http_x_forwarded_for"';
>
> access_log /var/log/nginx/access.log main;
> rewrite_log on;
> ....
> }
> ...
>
>
>
>
> nginx такой:
> nginx version: nginx/1.5.1
> built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
> TLS SNI support enabled
> configure arguments: --prefix=/opt/nginx --user=nginx --group=nginx
> --with-poll_module --with-file-aio --with-http_ssl_module
> --with-http_spdy_module --with-http_realip_module
> --with-http_addition_module --with-http_image_filter_module
> --with-http_geoip_module --with-http_sub_module --with-http_dav_module
> --with-http_flv_module --with-http_mp4_module
> --with-http_gzip_static_module --with-http_stub_status_module
> --with-pcre
Subject Author Posted

Помогите: m.domain.ru -> m.domain.ru/m, но...

point212 June 24, 2013 03:17AM

Re: Помогите: m.domain.ru -> m.domain.ru/m, но...

М.А. Мохначевский June 24, 2013 07:22AM

Re: Помогите: m.domain.ru -> m.domain.ru/m, но...

point212 June 25, 2013 01:31AM

Re: Помогите: m.domain.ru -> m.domain.ru/m, но...

PbIXTOP June 25, 2013 02:51AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 286
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