Nginxを実行しているserver1がserver2に "/ api"とその他いくつかのものを保持しながら、すべての "/"位置をserver2に転送する状況が発生しました。これはSSLの機能を維持しようとしています。 WP URLをhttp://test.example.comからhttps://example.comに移動しようとすると正面ページの読み込みが正しく行われますが、読み込みwp-admin
はリダイレクトが多すぎます。nginx上流のワードプレス定数リダイレクト
Server1にNginxは:
upstream webapp_url { server IP:80; } server { listen 443 ssl; server_name www.example.com example.com; access_log /var/log/nginx/example.log; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/server.key; ssl_ciphers RC4:HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location /files/ { root /home; access_log off; expires max; if ($request_filename !~* ^.*?\.(jpg)|(png)|(gif)|(pdf)){ add_header Content-Disposition: "$request_filename"; } } location/{ # proxy_pass http://site_url/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_cache_bypass $http_upgrade; proxy_set_header X-Example "1"; proxy_pass http://webapp_url/; }
これは、他のサーバーの罰金、ホームページをロードし、(私は管理者にそれを変更することができませんでしだから、混合コンテンツの警告が)すべての作業をリンクします。 WP siteurl
およびhome
は両方とも新しいアドレスに設定されます。
Server2のNginxは:
server { #listen 443 ssl; listen 80; server_name example.com test.example.com; client_max_body_size 30M; error_log /var/log/wordpress/error.log info; location/{ root /home/wordpress; try_files $uri $uri/ /index.php?q=$request_uri; index index.php index.html index.htm; } #ssl_certificate /etc/nginx/ssl/example.crt; #ssl_certificate_key /etc/nginx/ssl/example.key; #ssl_ciphers RC4:HIGH:!aNULL:!MD5; #ssl_prefer_server_ciphers on; error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # location ~ \.php$ { root /home/wordpress; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
ロード/wp-admin/
は(同じURLへの)無限のリダイレクトを開始します。私もwp-config.php
でそれを定義した:接続が安全であるかどうかを確認するために
define('WP_HOME','https://example.com'); define('WP_SITEURL','https://example.com');