2

I have the following nginx config:

upstream toshiba15 {
    server toshiba15.local:80;
}

server {
    listen 443 ssl;
    server_name my.domain.com;
    ssl_certificate /etc/nginx/ssl/startssl-nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/startssl-nginx.key;
    root /usr/share/nginx/html/;

    location /dev/ {
            proxy_pass http://toshiba15/;
            proxy_redirect http://toshiba15/ /dev/;
            proxy_set_header        Host    $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;
    }
}

Mostly works as intended, but one problem- when I specify a nonexistent sub-directory in the uri, it displays the content at the root of the proxied (toshiba15) server!

The proxied server has a stock nginx config- no changes.

EDIT: I resolved the subdomain problem by adding another server that returns 404, and using regexes for my server_names

Additionally, if I specify an undefined subdomain, it redirects to the root of the proxy server (my.domain.com)

Thanks!

0

Ok, I figured out what to do. On the upstream server I moved the root and index directives inside the location block and removed the tries.

On the proxy, to take care of the subdomain problem I set up a catch-all at the top without a servername and returned 404. I added a regex to the main domain name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.