質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

Q&A

1回答

830閲覧

Ghost やphpmyadminをhttpsで開こうとするとNot found や 503 bad gatewayになる[centos7 + Nginx]

keykey

総合スコア6

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

0グッド

0クリップ

投稿2021/05/03 05:35

編集2022/01/12 10:55

centos7 + Nginx の初心者です。皆様よろしくお願いいたします。
CerbotのSSLを使用しています。2つのドメインでindex.htmlなど静的ページ であればhttpsでの表示などできるようになりました。
GHOST CMSやphpmyadmin をインストールしてhttpでの表示はできますが、httpsで表示しようとするとNot found や bat gateway のエラーになってしまいます。

mywebsite1.com とmywebsite2.com の両方でSSLで の表示はできています。
GHOST CMSやphpmyadmin は mywebsite1.comのドメインで行おうとしています。
nginxの設定ファイルの書き方の問題だと思うのですが、何度書き方を変更しても上記の現象が改善されません。
正しい記述の方法を教えていただけますでしょうか?よろしくお願いいたします。

できるかぎり設定ファイルを分けて、綺麗に書くようにしましたがこの程度のレベルです。よろしくお願いいたします。

nginx -T nginx: [warn] conflicting server name "mywebsite1.com" on 0.0.0.0:443, ignored nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful # configuration file /etc/nginx/nginx.conf: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server { location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } # configuration file /etc/nginx/conf.d/default.conf: server { listen 443 ssl; server_name mywebsite2.com; charset UTF-8; access_log /var/log/nginx/mywebsite2-access.log main; ssl_certificate /etc/letsencrypt/live/mywebsite2.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mywebsite2.com/privkey.pem; root /var/www/html/mywebsite2; } server { listen 443 ssl; server_name mywebsite1.com; charset UTF-8; ssl_certificate /etc/letsencrypt/live/mywebsite1.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mywebsite1.com/privkey.pem; root /var/www/html/mywebsite1; location /phpMyAdmin { root /usr/share; index index.php index.html index.htm; try_files $uri $uri/ /index.php?$query_string; location ~ ^/phpMyAdmin/(.+.php)$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_intercept_errors on; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ .php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} } # configuration file /etc/nginx/fastcgi_params: 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 REQUEST_SCHEME $scheme; 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; # configuration file /etc/nginx/conf.d/ghost.conf: upstream ghost { server 127.0.0.1:2368; } server { listen 443 ssl http2; listen 80; server_name mywebsite1.com; ssl_certificate /etc/letsencrypt/live/mywebsite1.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mywebsite1.com/privkey.pem; access_log /var/log/nginx/ghost.access.log; error_log /var/log/nginx/ghost.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_set_header X-Forwarded-Proto https; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_set_header Host $host; proxy_pass http://ghost; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_X_forwarded_for; } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

まず、server_name mywebsite1.com; を記載している server { ... } 設定が重複しているので、1つにまとめる必要があります。

location /phpMyAdmin { ... } で、fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; で php-fpm に接続しようとしていますが、php-fpm はインストール・起動されていて、このソケットファイルで待ち受けているのでしょうか?
error_log を確認ください。

投稿2021/05/05 08:38

TaichiYanagiya

総合スコア12141

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

keykey

2021/05/05 09:38

ご回答ありがとうございます。早速修正してみます。初心者でして少し時間をください。それから、error_logということでしたが、これはどこのエラーログのことでしょうか?私が見ているところは404のnot found程度しか情報がなかったのですが。。。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問