背景
我们正在为想要一个“白标”解决方案的人运行一个项目(他们希望他们的网站的子域显示我们网站的某些页面,样式看起来像他们的)。我们倾向于这条路线的主要原因是他们的用户觉得他们没有离开原始网站(或他们是相关的)并且客户端坚持。
计划
将子域指向我们的服务器,但只允许它访问与此项目相关的页面(否则我们的常规网站页面会让人感到困惑)。我们的前端堆栈只是一个小型Nginx服务器,里面有一个单页面应用程序。我们没有从该站点的区域到其他区域的任何导航,但如果路径没有被阻止,人们仍然可以到达那里。我们想要访问的页面是:
//其中example.example.com只是other.com的别名
问题
答案 0 :(得分:2)
假设您的客户端拥有example.com
域并且您拥有example.org
域,则在客户端服务器上添加此配置应该可以解决问题
server {
listen 80;
server_name sub.example.com;
location /profiles/ {
# proxy pass all requests to example.org/relevant/profiles/folder
proxy_pass http://example.org/relevant/profiles/folder/;
proxy_redirect default;
}
location / {
# Return 404 for all other requests to sub.example.com
return 404;
}
}