大网数据广告活动
服务器运维问答

How do I provide domain masking

· 52CE 我爱测

I run a website foo.com . I want to provide domain masking for my clients who run bar.com . Specifically, they would like for xyz.bar.com to load the content from foo.com/abc such that the visitor never leaves the xyz.bar.com dom…

问题原文

原帖链接 · Timo · CC BY-SA 3.0

I run a website foo.com. I want to provide domain masking for my clients who run bar.com. Specifically, they would like for xyz.bar.com to load the content from foo.com/abc such that the visitor never leaves the xyz.bar.com domain.

This is a standard feature of many web services and it usually involves the bar.com people making a DNS entry for xyz.bar.com to point at an IP address (e.g. 123.0.0.2) given to them by foo.com.

But how do I set this up at the foo.com end?

  • Do I have to set up a separate IP address (123.0.0.xxx) for each bar.com subdomain?
  • What is the correct way to set up nginx at my end, so that a given xyz gets mapped to the appropriate abc?
  • Do I need to acquire certificates for xyz.bar.com and install them on my end?

Also as a general note, one xyz always corresponds to one abc, but there are many instances of these pairs. Any advice on how to automate the process is greatly appreciated.

Things that I have looked into and do not want:

  • iframes, this is work on the clients end, and out of technical scope for most of them.
  • URL rewriting et. al., this is a stop gap solution at best and complicates my application code with lost of client and /abc special casing.

已采纳解答

原帖链接 · Tero Kilkanen · CC BY-SA 3.0

Do I have to set up a separate IP address (123.0.0.xxx) for each bar.com subdomain?

No. One IP address can host multiple domains, this is implemented using virtual hosts in your web server software.

What is the correct way to set up nginx at my end, so that a given xyz gets mapped to the appropriate abc?

You set up a virtual host for xyz by using server_name xyz; directive in your nginx configuration.

Then you use root directive to specify the desired root directory for that domain on your server.

You can also configure nginx to use application server for that domain.

Do I need to acquire certificates for xyz.bar.com and install them on my end?

Yes, you need to have valid certificates for all virtual hosts matching their domain names that use TLS on your server.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。