質問編集履歴

1

仮のURL「hogehoge.jp」を「example.jp」に変更。error.logの内容と実行環境を追記。

2017/11/21 00:35

投稿

pdj_kt
pdj_kt

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- 例えば「**http://xxx.hogehoge.jp**」(xxxはサブドメイン)にアクセスした際、ブラウザに表示されるURLはこのままで、実際には「**http://hogehoge.jp/xxx/**」を表示したいと思っています。
1
+ 例えば「**http://xxx.example.com**」(xxxはサブドメイン/example.comは仮のURL)にアクセスした際、ブラウザに表示されるURLはこのままで、実際には「**http://example.com/xxx/**」を表示したいと思っています。
2
2
 
3
3
 
4
4
 
@@ -10,13 +10,13 @@
10
10
 
11
11
  listen 80;
12
12
 
13
- server_name ~^(.*).hogehoge.jp$;
13
+ server_name ~^(.*).example.com$;
14
14
 
15
15
 
16
16
 
17
17
  location / {
18
18
 
19
- proxy_pass http://hogehoge.jp/$1;
19
+ proxy_pass http://example.com/$1;
20
20
 
21
21
  }
22
22
 
@@ -27,3 +27,31 @@
27
27
  すると「502 Bad Gateway」が返されてしまいます。
28
28
 
29
29
  「$1」の部分を「xxx」と固定にすると正しい結果が得られるので、「$1」がうまく取得できないないのだと思いますが、どのようにしたら良いでしょうか。
30
+
31
+
32
+
33
+ ---
34
+
35
+
36
+
37
+ ###2017.11.21追記
38
+
39
+
40
+
41
+ error.logの内容は下記の通りです。
42
+
43
+ ```log
44
+
45
+ 2017/11/21 00:05:27 [error] 2961#2961: *3 no resolver defined to resolve example.com, client: 192.168.10.1, server: ~^(.*).example.com$, request: "GET / HTTP/1.1", host: "xxx.example.com"
46
+
47
+ 2017/11/21 00:05:27 [error] 2961#2961: *3 no resolver defined to resolve example.com, client: 192.168.10.1, server: ~^(.*).example.com$, request: "GET /favicon.ico HTTP/1.1", host: "xxx.example.com", referrer: "http://xxx.example.com/"
48
+
49
+ ```
50
+
51
+ また、実行環境についてはwin8.1にVirtualBox + Vagrantで環境構築し、hostsに下記を設定しています。
52
+
53
+ ```hosts
54
+
55
+ 192.168.10.10 example.com xxx.example.com
56
+
57
+ ```