重定向 nginx 后更改 URL

Change URL after redirect nginx

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

所以我调用例如www.page.de and redirect it to myip/outfitcreator. But instead of myip I want to have www.page.de/outfitcreator

有解决办法吗?

这是我的 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;

}

}

非常感谢!

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