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

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

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

Kibanaとは、ElasticSearchをバックエンドとする、データを可視化するGUIツールです。

CentOS

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

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

GitLab

GitLabは Gitoliteをブラウザから管理できるようにする Rubyアプリケーションで、 GitHubのようなサービスをクローズドな環境に独自で構築できるように 公開されたものです。

Q&A

1回答

9075閲覧

Apacheの複数サイトへのリバースプロキシについて

mercurius51

総合スコア12

Kibana

Kibanaとは、ElasticSearchをバックエンドとする、データを可視化するGUIツールです。

CentOS

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

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

GitLab

GitLabは Gitoliteをブラウザから管理できるようにする Rubyアプリケーションで、 GitHubのようなサービスをクローズドな環境に独自で構築できるように 公開されたものです。

0グッド

0クリップ

投稿2019/05/24 16:58

現在、Apacheのリバースプロキシ機能を使用して以下のような構成の環境を構築したいと考えています。
![イメージ説明説明]
(419e985e9606df496f6bdd4b34004835.jpeg)](1eca775e812b51a228c84e0a2e5ad2bc.jpeg)

※Mattermost部分はまだ構築できていません
この構成の中で、設定を一つずつ適用させた場合にはそれぞれのサービスに問題なくアクセスできることは確認できました。
しかし、同時にこれらを行うことが難しい状態です。
具体的いま分かっていることとしては
(1)KibanaとWordPressの定義は共存できる
(2)GitLabの定義とその他の定義が共存できない

事象としては、GitLabの定義を有効にしてhttps://mydomain.com/kibana/https:/mydomain.com/blog/にブラウザでアクセスすると、

Not found "/kibana/"

このような画面が表示され、思ったように動きません
この状態のときはGitLabにはアクセスが可能です

Apacheのログを見ましたが、上記ページを返しているメッセージが出ているのみであまり役に立ちませんでした。
なお、このログはプロキシによって出力されています。
そのため、/blogあてのリクエストもプロキシを通っていることになります。
末尾にコンフィグを掲出しますが、プロキシを通らないように設定はしてあります。

xx.xx.xx.xx - - [25/May/2019:01:34:38 +0900] "GET /blog/ HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Android 9; Mobile; rv:67.0) Gecko/67.0 Firefox/67.0"

どうにかして上記環境を構築したいと思っております、ご助言いただけますと幸いです。
よろしくお願いいたします。

/etc/httpd/conf/httpd.conf(コメント行除外)

ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache ServerName mydomain.com:80 <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/var/www/html" <Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig /etc/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> AddDefaultCharset UTF-8 <IfModule mime_magic_module> MIMEMagicFile conf/magic </IfModule> EnableSendfile on IncludeOptional conf.d/*.conf

/etc/httpd/conf.d/gitlab_proxy.conf

Alias /blog /usr/share/blog <Directory "/usr/share/blog"> Options FollowSymLinks AllowOverride All Require all granted </Directory> ProxyPass /blog ! <VirtualHost *:80> ServerName mydomain.com ServerSignature Off RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L] ProxyPass /blog ! ProxyPass /kibana ! </VirtualHost> <VirtualHost *:443> SSLEngine on SSLProtocol all -SSLv2 SSLHonorCipherOrder on SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS" Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains" SSLCompression Off SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem SSLCACertificateFile /etc/letsencrypt/live/mydomain.com/chain.pem ServerName mydomain.com ServerSignature Off ProxyPreserveHost On AllowEncodedSlashes NoDecode <Location /gitlab/> Require all granted ProxyPassReverse http://127.0.0.1:8181 ProxyPassReverse http://mydomain.com/gitlab/ </Location> RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_URI} ^/uploads/.* RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE] RequestHeader set X_FORWARDED_PROTO 'https' RequestHeader set X-Forwarded-Ssl on DocumentRoot /home/git/gitlab/public ErrorDocument 404 /404.html ErrorDocument 422 /422.html ErrorDocument 500 /500.html ErrorDocument 502 /502.html ErrorDocument 503 /503.html LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded ErrorLog /var/log/httpd/logs/YOUR_SERVER_FQDN_error.log CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_forwarded.log common_forwarded CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_access.log combined env=!dontlog CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN.log combined </VirtualHost>

/etc/httpd/conf.d/kibana.conf

<VirtualHost *:443> ProxyRequests off SSLEngine on SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem <Location /kibana/> ProxyPass http://192.168.xx.xx:5601/ ProxyPassReverse https://mydomain.com/kibana/ ProxyPassReverseCookieDomain 192.168.xx.xx:5601 mydomain.com ProxyPassReverseCookiePath / /kibana/ RewriteRule "^/kibana/(.*)$" "/$1" [L,PT] Substitute "s|http://192.168.xx.xx:5601/|https://mydomain.com/kibana/|q" </Location> </VirtualHost>

/etc/httpd/conf.d/ssl.conf

Listen 443 https SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog SSLSessionCacheTimeout 300 SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin <VirtualHost mydomain.com:443> DocumentRoot "/var/www/html" ServerName mydomain.com:443 ErrorLog logs/ssl_error_log TransferLog logs/ssl_access_log LogLevel warn SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem <Files ~ ".(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost>

不足している情報等ありましたら、できる限りお伝えしたいと思います
よろしくお願いいたします

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

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

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

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

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

guest

回答1

0

同じドメイン名:ポートの組み合わせの VirtualHost は、複数設定できませんので同じ場合は、最初の記載された(読み込まれた)内容が有効になります。

おそらく Apache 起動時に VirtualHost が重複しているとメッセージが出いると思われます。

同じドメインの VirtualHost は、記載内容を整理して、1つの VirtualHost にまとめて記載するようにしてください。

設定ファイルを見た感じでは、 ssl.conf の中の VirtualHost に 他の conf ファイルの VirtualHost 設定の内容を入れるのが良いと思われます。

投稿2019/05/24 21:47

編集2019/05/24 21:48
CHERRY

総合スコア25171

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

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

mercurius51

2019/05/25 03:16 編集

ご回答ありがとうございます。 本日、ご教示いただいた内容を試してみました。 設定を整理し、一つのコンフィグにまとめたのですが、下記のエラーが出て起動できない状況となってしまいました。 調べてみたところモジュールがロードされていないという原因をよく見ましたが、変更する前のコンフィグでは動作していたためモジュールの有無が原因ではないと思いました。 しかし、それだと原因がわからず、といった状況です。 [systemctl status httpd] ============================ ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 土 2019-05-25 11:58:30 JST; 14min ago Docs: man:httpd(8) man:apachectl(8) Process: 23039 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Process: 23037 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 23037 (code=exited, status=1/FAILURE) 5月 25 11:58:30 reverse_proxy systemd[1]: Starting The Apache HTTP Server... 5月 25 11:58:30 reverse_proxy httpd[23037]: AH00526: Syntax error on line 63 of /etc/httpd/conf.d/ssl.conf: 5月 25 11:58:30 reverse_proxy httpd[23037]: Invalid command 'PreserveHost', perhaps misspelled or defined by a module not included in the server configuration 5月 25 11:58:30 reverse_proxy systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE 5月 25 11:58:30 reverse_proxy kill[23039]: kill: cannot find process "" 5月 25 11:58:30 reverse_proxy systemd[1]: httpd.service: control process exited, code=exited status=1 5月 25 11:58:30 reverse_proxy systemd[1]: Failed to start The Apache HTTP Server. 5月 25 11:58:30 reverse_proxy systemd[1]: Unit httpd.service entered failed state. 5月 25 11:58:30 reverse_proxy systemd[1]: httpd.service failed. ``` ============================ [/etc/httpd/conf.d/ssl.conf] ============================ Listen 443 https ProxyPass /blog ! SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog SSLSessionCache shmcb:/run/httpd/sslcache(512000) SSLSessionCacheTimeout 300 SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin SSLCompression Off ServerSignature off AllowEncodedSlashes NoDecode <VirtualHost mydomain.com:443> DocumentRoot "/var/www/html" ServerName mydomain.com:443 ErrorLog logs/ssl_error_log TransferLog logs/ssl_access_log LogLevel warn SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLHonorCipherOrder on SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS" Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains" SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem <Files ~ ".(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> <Location /gitlab/> Require all granted ProxyPassReverse http://127.0.0.1:8181 ProxyPassReverse http://mydomain.com/gitlab/ RewriteEngine on PreserveHost On RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_URI} ^/uploads/.* RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE] RequestHeader set X_FORWARDED_PROTO 'https' RequestHeader set X-Forwarded-Ssl on DocumentRoot /home/git/gitlab/public ErrorDocument 404 /404.html ErrorDocument 422 /422.html ErrorDocument 500 /500.html ErrorDocument 502 /502.html ErrorDocument 503 /503.html LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded ErrorLog /var/log/httpd/logs/YOUR_SERVER_FQDN_error.log CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_forwarded.log common_forwarded CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_access.log combined env=!dontlog CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN.log combined </Location> <Location /kibana/> SSLProxyCheckPeerCN off SSLProxyCheckPeerName off ProxyPass http://192.168.xx.xx:5601/ ProxyPassReverse https://mydomain.com/kibana/ ProxyPassReverseCookieDomain 192.168.50.7:5601 mydomain.com ProxyPassReverseCookiePath / /kibana/ RewriteRule "^/kibana/(.*)$" "/$1" [L,PT] Substitute "s|http://192.168.xx.xx:5601/|https://mydomain.com/kibana/|q" </Location> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> ============================
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問