Hestia で見つからないサイトを別のサーバーにリダイレクトする方法 - Nginx プロキシ マネージャー

Hestia で見つからないサイトを別のサーバーにリダイレクトする方法 - Nginx プロキシ マネージャー

私が望むのは:(Hestia 192.168.0.37 サーバー)でサイトが見つからない場合は、(Nginx プロキシ マネージャー 192.168.0.36)にリダイレクトすることです。

与えられた条件:

  1. ヘスティアサーバー 192.168.0.37
  2. Nginx プロキシ マネージャー 192.168.0.36
  3. テスト用サイト testsite.com (Nginx プロキシ マネージャーで作成) (Hestia にはレコードがありません)
  4. ヘスティアの投稿:
#netstat -nt4ulp | grep nginx
tcp        0      0 0.0.0.0:80 LISTEN /nginx: mast 
tcp        0      0 0.0.0.0:443 LISTEN /nginx: mast 
tcp        0      0 0.0.0.0:8083 LISTEN/nginx: master  
tcp        0      0 127.0.0.1:8084 LISTEN /nginx: mast 
#netstat -nt4ulp | grep apache
tcp        0      0 192.168.0.37:8443 LISTEN /apache2     
tcp        0      0 192.168.0.37:8080 LISTEN /apache2     
tcp        0      0 127.0.0.1:8081 LISTEN /apache2  

========================================================================

私は試します:

/etc/nginx/conf.d/192.168.0.37.confを編集します。

server {
    listen 80 default_server;
    server_name _;
    
    location / {
        proxy_pass http://192.168.0.36:80;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

server {
    listen 443 ssl default_server;
    server_name _;
    
        ssl_certificate     /usr/local/hestia/ssl/certificate.crt;
        ssl_certificate_key /usr/local/hestia/ssl/certificate.key;

    
    location / {
        proxy_pass https://192.168.0.36:443;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

========================================================================

私は努力する

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 15 Sep 2023 17:54:48 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://testsite.com/

そして、(Hestia サーバー 192.168.0.37) DocumentRoot /var/www/html/index.html から /etc/apache2/conf.d/192.168.0.37.conf のページを参照します。

Listen 192.168.0.37:8443
Listen 192.168.0.37:8080
<VirtualHost 192.168.0.37:8080>
    ServerName 192.168.0.37
    DocumentRoot /var/www/html2/
    Alias /error/ /var/www/document_errors/

</VirtualHost>

<VirtualHost 192.168.0.37:8443>
    ServerName 192.168.0.37
    DocumentRoot /var/www/html/
    Alias /error/ /var/www/document_errors/

    SSLEngine on
    SSLVerifyClient none
    SSLCertificateFile         /usr/local/hestia/ssl/certificate.crt
    SSLCertificateKeyFile      /usr/local/hestia/ssl/certificate.key

</VirtualHost>

なぜ、どうやって修正するのですか?

答え1

これはコメントであるべきですが、少し長いです。

ここで何を尋ねているのか分かりません。

nginx サーバーで SSL を終了する場合は、SSL 証明書が非常に強力であるか、すべてのサイトが nginx で個別のサーバーとして構成されているかのいずれかです。

(Hestia サーバー 192.168.0.37) からページを参照します。

はい、まさにこの設定から期待していた通りです。http[s]://192.168.0.36 を要求したところ、http[s]://192.168.0.36 が返されました。

動作を維持したい場合はhttps://192.168.0.36(サブネット外からはアクセスできません) 不明な仮想ホストに新しい動作を追加する場合は、プロキシに新しい名前の DNS レコードまたはホスト エントリと、Apache 内の対応する仮想ホストが必要です。

あるいは、正気な人なら同じ証明書で複数のサイトを操作しようとはしないので、nginx のデフォルト サーバーからリダイレクトを返すだけです。

関連情報