업데이트:

업데이트:

다른 서버와 외부 포트 80 및 443을 공유하는 Django 웹 앱이 있습니다. localhost역방향 프록시가 없어도 잘 작동하지만 활성화하면 모든 종류의 오류가 발생합니다.

역방향 프록시가 제대로 작동하도록 하는 방법은 무엇입니까?

역방향 프록시.conf:

      # SSL Certificate and other SSL configurations
      SSLProxyEngine on
      ProxyRequests on
      SSLProxyVerify require 
      SSLProxyCheckPeerCN on
      SSLProxyCheckPeerName on
      SSLProxyCheckPeerExpire on
      ProxyPreserveHost on
      RequestHeader set X-Forwarded-Proto https

      # Reverse Proxy Configuration
      ProxyPass "/" "https://192.168.1.83/"
      ProxyPassReverse "/" "https://192.168.1.83/"

      # Additional SSL configurations if needed

SSL-https conf 파일에 위의 프록시를 모두 리디렉션하고 포함 http했습니다 . https사이트는 정상적으로 운영되고 있습니다없이포함(즉, Include .../reverse-proxy.conf주석 처리된 경우). 역방향 프록시가 포함되면 다음을 얻습니다.

[Thu Jan 18 07:09:39.835368 2024] [ssl:error] [pid 46505:tid 133251102926528] [remote 192.168.1.83:443] AH02039: Certificate Verification: Error (20): unable to get local issuer certificate
[Thu Jan 18 07:09:39.835470 2024] [ssl:error] [pid 46505:tid 133251102926528] [remote 192.168.1.83:443] AH02040: Certificate Verification: Certificate Chain too long (chain has 2 certificates, but maximum allowed are only 1)
[Thu Jan 18 07:09:39.835773 2024] [proxy:error] [pid 46505:tid 133251102926528] (20014)Internal error (specific information not available): [client 119.74.38.81:51224] AH01084: pass request body failed to 192.168.1.83:443 (192.168.1.83), referer: https://acupunctureclassique.duckdns.org/
[Thu Jan 18 07:09:39.835832 2024] [proxy:error] [pid 46505:tid 133251102926528] [client 119.74.38.81:51224] AH00898: Error during SSL Handshake with remote server returned by /login/, referer: https://acupunctureclassique.duckdns.org/
[Thu Jan 18 07:09:39.835861 2024] [proxy_http:error] [pid 46505:tid 133251102926528] [client 119.74.38.81:51224] AH01097: pass request body failed to 192.168.1.83:443 (192.168.1.83) from 119.74.38.81 (), referer: https://acupunctureclassique.duckdns.org/

프런트 엔드에서:

Proxy Error
The proxy server could not handle the request

Reason: Error during SSL Handshake with remote server

Apache/2.4.58 (Ubuntu) Server at acupunctureclassique.duckdns.org Port 443

업데이트:

apachectl -S

VirtualHost configuration:
*:443                  acupunctureclassique.duckdns.org (/etc/apache2/sites-enabled/acu-le-ssl.conf:2)
*:80                   acupunctureclassique.duckdns.org (/etc/apache2/sites-enabled/acu.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

답변1

여기서 실제 문제는 채팅에서 토론한 후 사용자가 nginx를 사용하여 동일한 nginx 인스턴스로 트래픽을 프록시하여 깔끔한 리디렉션 루프를 생성하여 결국 너무 큰 헤더 오류 메시지로 이어지는 것으로 밝혀졌습니다.

> ProxyPass "/" "https://192.168.1.83/"

트래픽을 로 보냅니다 https://192.168.1.83. 당신은 이것이 Let's encrypt에서 발행한 인증서라고 주장하지만 LE는절대에 대한 인증서를 발급하지 않으며 192.168.1.83, 어떠한 공용 CA도 그러한 인증서를 발급하지 않습니다. 다음을 기억하세요.유효한인증서가 충분하지 않습니다.가지다예상되는 이름과 일치합니다. 이 경우에는 입니다 192.168.1.83. 귀하의 로그에도 이에 대한 내용이 매우 명시되어 있습니다.

몇 가지 대안이 있습니다.

  1. HTTP 사용
  2. 자체 서명된 인증서를 사용하고 다음을 사용하여 Apache가 이를 신뢰하도록 합니다.SSLProxyCACertificate지령.
  3. 유효한 도메인 이름을 사용하고 해당 도메인 이름에 대한 유효한 인증서를 취득하세요. 도메인 이름은 로 확인되거나 192.168.1.83에 추가될 수 있지만 /etc/hostsApache~ 할 것이다인증서의 호스트 이름과 일반 이름(또는 SAN)을 일치시킵니다.
  4. 장애를 입히다사용하여 이름 확인SSLProxyCheckPeerName = off
  5. 다음을 사용하여 확인을 비활성화합니다.SSLProxyVerify = none, 효과적으로 확인을 비활성화합니다. 이는 http를 사용하는 것과 거의 같습니다...

답변2

역방향 프록시를 사용하려면 /etc/apache2/sites-available에 가상 호스트를 생성해야 합니다. 다음은 VirtualHost 구성의 예입니다.

<VirtualHost *:80>
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com

    DocumentRoot /path/to/your/django/static/files

    Alias /static/ /path/to/your/django/static/files/
    <Directory /path/to/your/django/static/files>
        Require all granted
    </Directory>

    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com

    DocumentRoot /path/to/your/django/static/files

    Alias /static/ /path/to/your/django/static/files/
    <Directory /path/to/your/django/static/files>
        Require all granted
    </Directory>

    SSLEngine on
    SSLCertificateFile /path/to/your/ssl/certificate.crt
    SSLCertificateKeyFile /path/to/your/ssl/private.key
    SSLCertificateChainFile /path/to/your/ssl/chainfile.pem

    ProxyPass / https://localhost:8000/
    ProxyPassReverse / https://localhost:8000/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

https 부분은 선택 사항이므로 https가 필요하지 않으면 생략할 수 있습니다.

관련 정보