jansemrau
jansemrau

Reputation: 251

Change URL after redirect nginx

I host my domain at Strato and do a permanent redirect to my linux server. That works fine, but I want to change the URL so that their is not the IP of my server but the name of the original domain.

So I call for example www.page.de and redirect it to myip/outfitcreator. But instead of myip I want to have www.page.de/outfitcreator.

Is there any solution for that?

Here is my nginx file

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;

}

}

Thank you very much!

Upvotes: 0

Views: 401

Answers (1)

palindromeotter33
palindromeotter33

Reputation: 166

You might be overcomplicating things a tad–what I recommend is to create a DNS A record that ties your domain to the IP address for your server rather than doing a redirect (since it doesn’t seem like anything is really at Strato but instead is on your Linux server). The DNS record should point to the IP of your NGINX server, and you'll need to add a server_name to the server block to make sure it's handled correctly

Upvotes: 1

Related Questions