Nginx書き換えルールはブラウザのURLを変更します。私は同じ問題でthis one questionを見たが、それは私を助けない。NGINX書き換えルールの変更URL
nginxのバージョン:
################################################
# PROXY CACHE OPTIONS ##########################
################################################
proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=cache:30m max_size=1G inactive=60s;
proxy_temp_path /var/lib/nginx/proxy 1 2;
proxy_cache_key "$scheme$request_method$host$request_uri";
################################################
# Для заголовка WebSphere - WSIS
map $https $is_ssl {
default false;
on true;
}
rewrite_log on;
large_client_header_buffers 4 64k;
#upstream websphere {
# # Health-monitored upstream groups must be stored in shared memory
# zone backend 64k;
# server s1erinyet:10039;
# server s2erinyet:10039;
#}
################################################
## SERVER SECTION START ########################
################################################
server {
listen 80;
server_name taliat.erp;
################################################
### SSL FOR ESIA ###############################
################################################
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
################################################
# Разрешаем только определенные методы
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 444;
}
################################################
## LOCATION/SECTION START ####################
################################################
location/{
# here is haproxy on 8888
proxy_pass http://localhost:8888/;
proxy_cache cache;
proxy_ignore_headers Expires Cache-Control;
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
proxy_cache_lock on;
proxy_cache_min_uses 3;
proxy_cache_valid 200 302 120m;
proxy_cache_valid 404 1m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_cache_methods GET HEAD;
add_header X-Cache-Status $upstream_cache_status;
set $no_cache "";
# Any logged-in user's requests will not be cached and served directly by WebSphere. (Cookie based caching rule)
#if ($http_cookie ~* "JSESSIONID*"){
#set $no_cache 1;
#}
# These selected URI's below won't get cahced.
if ($request_uri ~* "(/wps/contenthandler.*)") {
set $no_cache 1;
}
proxy_no_cache $no_cache;
proxy_cache_bypass $no_cache;
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect
proxy_redirect off;
# Отключили буферинг чтобы портал не нервничал
proxy_buffering off;
proxy_read_timeout 300;
proxy_connect_timeout 600;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
# intercept errors on nginx side
#proxy_intercept_errors on;
################################################
### REWRITE RULES START ########################
################################################
set $original_uri $request_uri;
rewrite "^(\/)$" /wps/portal/ break;
rewrite "^/something\/*$" /wps/portal/Home/something/ break;
################################################
### REWRITE RULES END ##########################
################################################
################################################
### WEBSPHERE HEADERS START ####################
################################################
proxy_set_header X-Rewrite-URL $original_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header "$WSSC" $scheme;
proxy_set_header "$WSPR" $server_protocol;
proxy_set_header "$WSRA" $remote_addr;
proxy_set_header "$WSRH" $host;
proxy_set_header "$WSRU" $remote_user;
proxy_set_header "$WSSN" $server_name;
proxy_set_header "$WSSP" $server_port;
proxy_set_header "$WSIS" $is_ssl;
# Note that these vars are only available if
# NGINX was built with SSL
proxy_set_header "$WSCC" $ssl_client_cert;
proxy_set_header "$WSCS" $ssl_cipher;
proxy_set_header "$WSSI" $ssl_session_id;
# No equivalent NGINX variable for these headers.
proxy_hide_header "$WSAT";
proxy_hide_header "$WSPT";
proxy_hide_header "$WSFO";
proxy_pass_header Set-Cookie;
proxy_pass_header Set-Cookie2;
################################################
### WEBSPHERE HEADERS END ######################
################################################
}
################################################
## LOCATION/SECTION END ######################
################################################
################################################
## ERROR PAGES SECTION START ###################
################################################
error_page 500 502 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
internal;
}
# error 503 redirect to errror503.html
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /503.html break;
}
# error 404 page
error_page 404 /404.html;
location /404.html {
root /usr/share/nginx/html;
}
error_page 404 = @foobar;
location @foobar {
return 301 /;
}
################################################
## ERROR PAGES SECTION END #####################
################################################
}
################################################
## SERVER SECTION END ##########################
################################################
と私は見るために、ブラウザに期待する:
# nginx -v
nginx version: nginx/1.10.1
ここでは私の構成です http://servername/somethingをこれに代えて、私はhttp://servername/wps/portal/Home/something/を参照してください。私は何を:元URI保存
とヘッダに$ REQUEST_URI前と書き換え後の
proxy_set_header X-Rewrite-URL $request_uri;
として
セットX-書き換えURLを入れてください
set $original_uri $request_uri; proxy_set_header X-Rewrite-URL $original_uri;
Apache作業と同じ設定完全S:
RewriteEngine on
RewriteRule ^/something\/*$ /wps/portal/something [L,PT]
がUPDATE#1: 私はそれはproxy_pass
ディレクティブは、このケースを扱うことができ、あまりにも
'websphere'に送信されるURIを変更しようとするならば、' rewrite ... break'と '** rewrite ... last'を使わないでください。詳細については、[このドキュメント](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite)を参照してください。 –
@リチャードスミス私はブレークを試みた。それは助けにはならない。 – dikkini