Задать вопрос
  • Nginx переадресация с директории на поддомен?

    @gromovnk812 Автор вопроса
    Так, вот мой конфиг, полагаю, это говнокод, но оно работает, и поэтому вдруг кому пригодится

    server {
    
        server_name example www.example;
    
        location / {
            root /var/www/example;
            index index.html index.htm ;
            try_files $uri $uri/ /dir/index.html =404;
        }
    
        listen [::]:443 ssl; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/example/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/example/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    }
    
    server {
        server_name *.example;
        root /var/www/example/ddd/$1;
        index index.html index.htm ;
    
        location / {
    
            try_files $uri $uri/ /ddd/index.html =404;
        }
    
        listen [::]:443 ssl; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/example-0001/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/example-0001/privkey.pem; # managed by Certbot
    
    }
    
    server {
        if ($host = example) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
        listen 80;
        listen [::]:80;
        server_name example www.example;
        return 404; # managed by Certbot
    
    }
    Написано