0

! I have implemented a WebApp and SQL-DB. added custom domain and SSL certificates (which bought at CA).

for SSL offloading purpose we configured an azure application gateway. with all setup.

next, we configured azure traffic manager so that traffic manager decide active web app routing.

our concern is when I adding the CNAME record for traffic manager in GoDaddy it is routing to WebApp, everything is great.

but when I search "xxxx.com" Digwebinterface it shows all connections to WebApp

in this, I took the traffic manager CNAME record and added to another domain then the duplicate domain also accessing all my content of the website and even create a record in SQL also.

in this scenario I losing my website restriction unauthorized domain can map site

any suggestion and insights it would be grateful to

thank you

4

1 回答 1

0

简单的方法是在您的代码中创建一个过滤器,用于检查请求标头的主机,以允许或拒绝来自不同域的访问。

这是我在 Node.js 中的示例代码,带有express.

const express = require('express')
const app = express()
const port = 3000

const allowedHosts = [`localhost:${port}`]

var domainFilter = function(req, res, next) {
    if(allowedHosts.includes(req.headers.host)) {
        next()
    } else {
        res.status(403).end()
    }
}

app.use(domainFilter)

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))

它将允许来自或localhost:3000拒绝来自127.0.0.1:3000或其他人的请求,如下图所示。

图 1. 允许来自的请求localhost:3000

在此处输入图像描述

图 2. 拒绝127.0.0.1:3000或其他人

在此处输入图像描述

希望能帮助到你。

于 2019-08-01T08:24:30.073 回答