【问题标题】:Change URL after redirect nginx重定向nginx后更改URL
【发布时间】:2022-01-15 01:13:00
【问题描述】:

我在 Strato 托管我的域并永久重定向到我的 linux 服务器。 这很好,但我想更改 URL,以便它们不是我服务器的 IP,而是原始域的名称。

所以我调用例如 www.page.de 并将其重定向到 myip/outfitcreator。但是我想要www.page.de/outfitcreator而不是myip。

有什么解决办法吗?

这是我的 nginx 文件

server {
    listen 80;
    server_name xx.xx.xxx.xxx;
location / {
    root /var/www/kioskJPE/html;
    index index.html;
}   

location /upload {
    alias /var/www/fileUpload/html/upload;
    
}
location /downloadfiles{
    alias /var/www/fileUpload/html;
    
}

location /uploadFiles {
    proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
}
location /outfitcreator {
    alias /var/www/outfitcreator/html;

}

}

非常感谢!

【问题讨论】:

    标签: linux http nginx server


    【解决方案1】:

    您可能有点过于复杂了——我建议创建一个 DNS A 记录,将您的域与您的服务器的 IP 地址联系起来,而不是进行重定向(因为在 Strato 上似乎没有任何东西而是在您的 Linux 服务器上)。 DNS 记录应该指向您的 NGINX 服务器的 IP,并且您需要将 server_name 添加到服务器块以确保正确处理它

    【讨论】:

    • 是的,同时我添加了一条 A 记录,这样当我调用域时它会重定向到我的服务器。但它当然只重定向到主页而不是我想要的路径。有解决办法吗?
    • 在我正确配置我的 nginx 后,它解决了我的问题
    猜你喜欢
    • 2016-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 2012-04-27
    • 1970-01-01
    相关资源
    最近更新 更多