B
B
BloodVIRUS2019-04-28 13:42:12
Nginx
BloodVIRUS, 2019-04-28 13:42:12

How to display the site on a subdirectory inside the nginx config?

Hello. There is a server, ubuntu on which nginx is spinning.
Directory with configs /etc/nginx/sites-primary/
Inside each site has its own config, the structure of which is something like this:

server {
    listen 80;
    server_name                     site1..com;
    root                            /var/www/site1.com;

  location / {
        try_files               $uri $uri/ @rewrite;
    }
    location /index.html {
        rewrite                 / / permanent;
    }
 
    location ~ ^/(.*?)/index\.html$ {
        rewrite                 ^/(.*?)/ // permanent;
    }
    location @rewrite {
        rewrite                 ^/(.*)$ /index.php?q=$1;
    }
    location ~ \.php$ {
 
        include                 fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass    backend-valhalla;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|bmp)$ {
        #access_log           off;
        expires                      10d;
        error_page 404 = @fallback;
        break;
    }
   
    location ~* ^.+\.(css|js)$ {
        #access_log           off;
        charset utf-8;
        expires                      epoch;
        error_page 404 = @fallback;
        break;
    }
    location @fallback {
        rewrite ^/(.*)/[^/]+$ /editor/default.png redirect;
    }

}

There was a need to make the following feint:
When we open site1.com/control/ - then we should display the content of site2.com at this address. At the same time, if I follow links inside site1.com/control/ - it should go inside site1.com, and not open
site2.com
hallo_world.html should open the contents of the url above.
Adding a directive to the site1.com.conf config
location ~* ^/control/ {
    root                            /var/www/site1.com;
    }

Gives nothing.
The second day I sleep with Google, I can not find a solution ..

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question