搭建了 mesos+marathon 的环境,直接访问 192.168.0.2:5050 ( mesos )和 192.168.0.2:8080 ( marathon )是可以的。 但想利用另外一个 IP 实现集中访问,比如 192.168.0.99/mesos , 192.168.0.99/marathon 这种访问方式。 配置了一下,试了下面几种配置方式,但都报 404 错误,
server {
listen 80;
server_name 192.168.0.99;
location /mesos {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:5050;
}
location /marathon {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:8080;
}
}
或者
server {
listen 80;
server_name 192.168.0.99;
location /mesos/(.) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:5050;
}
location /marathon/(.) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:8080;
}
}
或者
server {
listen 80;
server_name 192.168.0.99;
location /mesos {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:5050/;
}
location /marathon {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.2:8080/;
}
}
实现 192.168.0.99/mesos , 192.168.0.99/marathon 这种访问方式,要如何配置呢?
1
majinjing3 2016-08-31 18:53:38 +08:00 via Android
proxy_pass 参数可能不对,建议去官方网站看下文档,
|
2
majinjing3 2016-08-31 18:56:37 +08:00 via Android
|
3
majinjing3 2016-08-31 19:06:32 +08:00 via Android 1
location /mesos/, 8080/,都加上 /
|
4
chenzhiwei 2016-08-31 19:10:23 +08:00 1
|
5
ryd994 2016-08-31 21:13:40 +08:00 1
server {
listen 80; server_name 192.168.0.99; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; location /mesos/ { proxy_pass http://192.168.0.2:5050/; } location /marathon/ { proxy_pass http://192.168.0.2:8080/; } } 原因: proxy_pass 不加 / 的话,就会 pass 到 http://192.168.0.2:5050/mesos/... proxy_pass 含路径时,会用 pass 里的路径部分,替换 location 的路径部分 |
6
akira 2016-08-31 21:35:47 +08:00
测试的时候, 可以看下不同参数对应的目标站的访问记录,这样会更清楚
|