34

アイデアは、着信リクエストを受け取りhttp://abc.example.com/...、に書き換えることです。http://example.com/abc/...

これは、301/302リダイレクトを使用するのに十分簡単です。

# rewrite via 301 Moved Permanently
server {
  listen 80;
  server_name abc.example.com;
  rewrite ^ $scheme://example.com/abc$request_uri permanent;
}

秘訣は、同じNginxインスタンスを指しているときに、このURLをクライアントに対して透過的に変更することです。abc.example.comexample.com

言い換えると、Nginxは、要求されexample.com/abc/...たときから、別のクライアントの往復なしでコンテンツを提供できますか?abc.example.com/...

開始点の構成

301でタスクを実行するNginx構成:

# abc.example.com
server {
  listen 80;
  server_name abc.example.com;
  rewrite ^ $scheme://example.com/abc$request_uri permanent;
}

# example.com
server {
  listen 80;
  server_name example.com;
  location / { 
    # ...
  }
}
4

1 に答える 1

43
# abc.example.com
server {
  listen 80;
  server_name abc.example.com;
  location / {
    proxy_pass http://127.0.0.1/abc$request_uri;
    proxy_set_header Host example.com;
  }
}
于 2013-01-24T02:09:15.467 に答える