nginxはドメイン名のアクセスを別のドメイン名に移動します。
2478 ワード
目的:
オンライン環境のドメイン名を変更する必要があるので、古いドメイン名test.xx.comを新しいドメイン名test.yy.comにジャンプする必要があります。
オンライン上のnginxでは、80と443を一つのconfファイルに配置し、古いhttpにアクセスすると新しいhttpにジャンプし、古いhttpsにアクセスすると新しいhttpsにジャンプし、オンライン上の環境を新たに設定してテストを行います。
インターネットでいくつかのインテンx内蔵変数のまとめを探しました。
1、ポートを使ってジャンプを判断する
オンライン環境のドメイン名を変更する必要があるので、古いドメイン名test.xx.comを新しいドメイン名test.yy.comにジャンプする必要があります。
オンライン上のnginxでは、80と443を一つのconfファイルに配置し、古いhttpにアクセスすると新しいhttpにジャンプし、古いhttpsにアクセスすると新しいhttpsにジャンプし、オンライン上の環境を新たに設定してテストを行います。
インターネットでいくつかのインテンx内蔵変数のまとめを探しました。
nginx $ , 。 , 。
$arg_PARAMETER :GET PARAMETER 。
$args GET 。 ,foo=123&bar=blahblah;
$binary_remote_addr 。
$body_bytes_sent
$content_length Content-length 。
$content_type Content-Type 。
$cookie_COOKIE cookie COOKIE 。
$document_root root 。
$document_uri $uri 。
$host (Host) , , server ( server server_name )。 , 。
$hostname gethostname
$http_HEADER HTTP ,HEADER HTTP ,- _( ), :$http_user_agent(Uaer-Agent ), $http_referer...;
$sent_http_HEADER HTTP ,HEADER HTTP ,- _( ), : $sent_http_cache_control, $sent_http_content_type...;
$is_args $args , "?", ""。
$limit_rate 。
$nginx_version nginx 。
$query_string $args 。
$remote_addr IP 。
$remote_port 。
$remote_user Auth Basic Module 。
$request_filename , root alias URI 。
$request_body (0.7.58+) 。 proxy_pass fastcgi_pass location 。
$request_body_file 。
$request_completion , "OK"; 。
$request_method , GET POST。
0.8.20 , main request , , 。
$request_uri URI, , $uri URI。
$scheme , http https, rewrite ^(.+)$ $scheme://example.com$1 redirect;
$server_addr , , , listen bind 。
$server_name 。
$server_port 。
$server_protocol , HTTP/1.0 HTTP/1.1。
$uri URI( , $args), $request_uri , , index 。 , /foo/bar.html
テストに成功した2つの構成は、1、ポートを使ってジャンプを判断する
if ($server_port = 80 ) {
return 301 http://www.jk.com;
}
if ($server_port = 443 ) {
return 301 https://www.jk.com;
}
2、判定プロトコルを使ってジャンプする location = / {
rewrite ^(.+)$ $scheme://www.jk.com$1 redirect;
}
httpをhttpにジャンプしてもいいです。 httpsはhttpsにジャンプします