前提・実現したいこと
nginxで稼働するサーバー(サーバーA)からリバースプロキシを設定し、apacheで稼働するサーバー(サーバーB)にMTを動かしています。
ドメインはexample.com、ドメインはサーバーAのIPにむいています。
サーバーAにはWordPressが動いており、example.comだとWP、サブディレクトリ example.com/sub だとMTを表示するよう設定しています。
WordPress(サーバーA)
https://www.example.com
MovableType(サーバーB)
http://www.example.com/sub
上記の通り現在WordPressはSSL化しておりますが、MTはSSLしていないため、MTをSSL化したいと考えているのですが、リバースプロキシの設定がうまくいかずMTをうまくSSL化できていません。
現状のnginxのconf設定
nginx.conf
1 2#server { 3# listen 80; 4# listen 443; 5# server_name example.com; 6# return 301 https://www.example.com$request_uri; 7#} 8 9server { 10 listen 443 default_server; 11 ssl on; 12 13 root /var/www/html; 14 index index.php index.html index.htm; 15 16 ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; 17 ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; 18 19 try_files $uri $uri/ /html/example/index.php?$args; 20 server_name example.com; 21 22 location ^~ /sub/ { 23 proxy_pass http://xxx.xxx.xxx.xxx/sub; 24 proxy_redirect http:// https://; 25 proxy_set_header Host $host; 26 proxy_set_header X-Real-IP $remote_addr; 27 proxy_set_header X-Forwarded-Proto $scheme; 28 proxy_set_header X-Forwarded-Host $host; 29 proxy_set_header X-Forwarded-Server $host; 30 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 31 } 32 33 location / { 34 ssi on; 35 ssi_last_modified on; 36 try_files $uri $uri/ @wordpress; 37 } 38 39 location ~ .html$ { 40 root html; 41 fastcgi_pass 127.0.0.1:9000; 42 fastcgi_index index.html; 43 fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 44 include fastcgi_params; 45 } 46 47 location ~ .php$ { 48 try_files $uri @wordpress; 49 fastcgi_index index.php; 50 fastcgi_split_path_info ^(.+.php)(.*)$; 51 fastcgi_pass 127.0.0.1:9000; 52 fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 53 include fastcgi_params; 54 } 55 56 location @wordpress { 57 fastcgi_index index.php; 58 fastcgi_split_path_info ^(.+.php)(.*)$; 59 fastcgi_pass 127.0.0.1:9000; 60 fastcgi_param SCRIPT_FILENAME /var/www/html/example/index.php; 61 include fastcgi_params; 62 } 63} 64 65server { 66 67 listen 80; 68 root /var/www/html; 69 70 index index.php index.html index.htm; 71 72 try_files $uri $uri/ /html/example/index.php?$args; 73 74 server_name example.com; 75 76 # reverse proxy 77 location /sub/ { 78 proxy_pass http://xxx.xxx.xxx.xxx/sub/; 79 } 80 81 location / { 82 ssi on; 83 ssi_last_modified on; 84 try_files $uri $uri/ @wordpress; 85 } 86 87 location ~ /wp-login.php.* { 88 fastcgi_pass 127.0.0.1:9000; 89 fastcgi_index index.php; 90 fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 91 include fastcgi_params; 92 } 93 94 location ~ .php$ { 95 try_files $uri @wordpress; 96 fastcgi_index index.php; 97 fastcgi_split_path_info ^(.+.php)(.*)$; 98 fastcgi_pass 127.0.0.1:9000; 99 fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; 100 include fastcgi_params; 101 } 102 103 location @wordpress { 104 fastcgi_index index.php; 105 fastcgi_split_path_info ^(.+.php)(.*)$; 106 fastcgi_pass 127.0.0.1:9000; 107 fastcgi_param SCRIPT_FILENAME /var/www/html/example/index.php; 108 include fastcgi_params; 109 } 110} 111
現状、上記ののような設定を行っておりまして、https://example.com/sub にアクセスすると、http://example.com/sub が表示されます。
#proxy_pass http://xxx.xxx.xxx.xxx/sub; proxy_pass http://xxx.xxx.xxx.xxx/sub2;
不可解なのが、上記のように変更しても接続先が変更されず、locationの優先順位などが間違っているのかと思いましたが、さっぱりわかりません。
当方インフラに詳しくないため、どなたかわかるようであれば詳しく教えていただけると助かります。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/17 04:52 編集
2020/01/29 08:54