Nginx と php5-fpm での予期しないリダイレクト

Nginx と php5-fpm での予期しないリダイレクト

ウェブホスティングの経験はあまりありませんが、WordPress サイトをセットアップしたいと思っていましたが、予期しないリダイレクトの問題が発生していたため、nginx 構成全体を消去しましたが、リダイレクトはまだ発生しています。リダイレクト方法が見つからないため、その理由はわかりません。

私が持っているものは次のとおりです:

nginx.conf:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
}

http {

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;


        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip off;
        gzip_disable "msie6";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

サイト対応フォルダに 1 つだけ

sites-enabled# ls
wordpress

server {
        listen   80;

        access_log /var/log/nginx/wordpress-access.log;
        error_log /var/log/nginx/wordpress-error.log;

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

        server_name localhost;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on a UNIX socket
        location ~ \.php$ {
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
}

fastcgi.conf:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

wordpress フォルダはデフォルトのダウンロードです:

/var/www/wordpress# ls -la
total 188
drwxr-xr-x  5 www-data www-data  4096 Oct  6 10:52 .
drwxrwxrwx 54 www-data root      4096 Oct  6 10:52 ..
-rw-r--r--  1 www-data www-data   418 Sep  2 22:33 index.php
-rw-r--r--  1 www-data www-data 19930 Sep  2 22:33 license.txt
-rw-r--r--  1 www-data www-data  7360 Sep 15 09:26 readme.html
-rw-r--r--  1 www-data www-data  4951 Sep  2 22:33 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Sep 15 09:58 wp-admin
-rw-r--r--  1 www-data www-data   271 Sep  2 22:33 wp-blog-header.php
-rw-r--r--  1 www-data www-data  5007 Sep  2 22:33 wp-comments-post.php
-rw-r--r--  1 www-data www-data  2749 Oct  6 10:54 wp-config.php
-rw-r--r--  1 www-data www-data  2764 Sep  2 22:33 wp-config-sample.php
drwxr-xr-x  4 www-data www-data  4096 Sep 15 09:58 wp-content
-rw-r--r--  1 www-data www-data  3286 Sep  2 22:33 wp-cron.php
drwxr-xr-x 12 www-data www-data  4096 Sep 15 09:58 wp-includes
-rw-r--r--  1 www-data www-data  2380 Sep  2 22:33 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3123 Sep  2 22:33 wp-load.php
-rw-r--r--  1 www-data www-data 34669 Sep  2 22:33 wp-login.php
-rw-r--r--  1 www-data www-data  8252 Sep  2 22:33 wp-mail.php
-rw-r--r--  1 www-data www-data 11062 Sep  2 22:33 wp-settings.php
-rw-r--r--  1 www-data www-data 25124 Sep  2 22:33 wp-signup.php
-rw-r--r--  1 www-data www-data  4035 Sep  2 22:33 wp-trackback.php
-rw-r--r--  1 www-data www-data  3055 Sep  2 22:33 xmlrpc.php
root@DMZ-Server:/var/www/wordpress# nano index.html

nginx は正しいポートで実行されているようです。

netstat -apn | grep 80
tcp        0      0 0.0.0.0:80    0.0.0.0:*    LISTEN      20612/nginx

しかし、localhost でサイトにアクセスすると、ログ (wordpress-acess.log) のいずれにも、これが表示されます。そして、このエラーが表示されるのは、時々だけです (これは非常に奇妙です)。

127.0.0.1 - - [06/Oct/2015:11:51:17 -0500] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.2.0"

その後、localhost:8090 に強制的にリダイレクトされます。まだ理由はわかりません。php5-fpm ログにも異常は表示されません。IPTables -nat -L をチェックして何か表示されるか確認しましたが、何も表示されませんでした。何かアイデアはありますか?

答え1

申し訳ありません。どうやら、かなり前に別のコンピューターから WordPress データベースをセットアップしていたようで、この WordPress インスタンスは、データベースにポート リダイレクトがセットアップされた、すでに構成されたデータベースを使用していました。データベースを消去すると、まさにその問題が修正されました。(まだ http だけで WordPress を実行することはできません。何らかの理由で https が強制されますが、その問題は修正できると思います)。

関連情報