Wordpress с NGINX в качестве прокси-сервера: нет доступа к wp-admin (502 плохой шлюз)

У меня есть сервер с проектом Django и блог Wordpress, Я использую Nginx для обслуживания двух доменов через локальный порт (8001 для GUnicorn и 8081 для Apache)

Я установил следующий файл Nginx для своего сайта WordPress, но у меня есть доступ только к домашней странице. Остальных страниц 502. Я не понимаю, чего мне не хватает!

Nginx: Nginx.conf

worker_processes 1;

events {

    worker_connections 1024;
}

http {

    sendfile on;

    gzip              on;
    gzip_http_version 1.0;
    gzip_proxied      any;
    gzip_min_length   500;
    gzip_disable      "MSIE [1-6]\.";
    gzip_types        text/plain text/xml text/css
                      text/comma-separated-values
                      text/javascript
                      application/x-javascript
                      application/atom+xml;


    # Configuration for Nginx
    server_names_hash_bucket_size 64;
    server {
    return 404;
    }
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

wordpress.conf

# WordPress single site rules.
# Designed to be included in any server {} block.
# Upstream to abstract backend connection(s) for php
upstream php {
        #server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:8081;
}

server {
        ## Your website name goes here.
        server_name www.simple-ripple.com  simple-ripple.com;
        ## Your only path reference.
        root /var/www;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?q=$uri$args;
        proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $http_host;
             proxy_set_header X-NginX-Proxy true;
        include proxy_params; 
        proxy_pass http://127.0.0.1:8081; 
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #fastcgi_split_path_info ^(/wp)(/.*)$;
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;

        }

        #location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        #        expires max;
        #        log_not_found off;
        #}
}
0
задан 7 November 2017 в 16:31
1 ответ

Um meinen Kommentar zu Ihrer Frage zu erweitern, verwenden Sie bitte eine ähnliche Konfiguration für Ihren vhost unter WordPress und PHP-Fpm

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

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

    fastcgi_pass YOURBACKEND;
    fastcgi_index index.php;
    include fastcgi.conf;
}
0
ответ дан 5 December 2019 в 07:09

Теги

Похожие вопросы