Radzhab
@Radzhab

Как совместить два конфига в nginx?

Есть nginx, который выступает в роли реверсивного сервера.

server {
        server_name xxx.ru http2;
        resolver 8.8.8.8 8.8.4.4 valid=300s;
        resolver_timeout 5s;
        add_header Strict-Transport-Security "max-age=31536000" always;
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        gzip on;
        gzip_proxied any;
        gzip_types
                        text/css
                        text/javascript
                        application/javascript
                        application/json
                        text/xml
            text/json;

        location / {
                proxy_pass http://localhost:3000/;
        }

        location /assets/ {
                proxy_pass http://localhost:3000/assets/;
        }

Стоит задача дополнительно поднять wordpress. Поставил php, mysql. Дал права на папку /var/www/wordpress, куда извлек архив сайта. При переходе по урлу https://xxx.ru/wp/index.php пишет - 404 файл не найден

location / {
                proxy_pass http://localhost:3000/;
        }

        location /assets/ {
                proxy_pass http://localhost:3000/assets/;
        }

        root /var/www/wordpress;
        index index.php index.html index.htm;


        location /wp {
             try_files $uri /index.html index.php;
        }


        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi.conf;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            #include fastcgi_params;
            fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

        }
  • Вопрос задан
  • 64 просмотра
Пригласить эксперта
Ответы на вопрос 1
Viji
@Viji
Associate DevOps Engineer
Попробуй внизу server block:

server {
....
# locations for proxy pass
....
location /wp/ {
root /var/www/wordpress;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

}
. . .
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы