ProxyPass와 함께 사용하면 Apache 별칭이 무시됩니다.

ProxyPass와 함께 사용하면 Apache 별칭이 무시됩니다.

설치하려고 하는데요터내 서버에서 nginx 대신 apache를 사용하고 싶습니다. 그만큼설치 설명서"번역"하려는 nginx 구성 파일만 나열합니다.

구성은 세 가지 다른 프록시 경로로 구성됩니다. 첫 번째 경로는 Docker 컨테이너로 연결되고 두 번째 경로(/공전/) 스타일시트 및 이와 유사한 항목이 있는 디렉토리로 이동하고 마지막 항목은 유닉스 도메인 소켓으로 이동합니다.

내 경우에는 첫 번째 경로가 작동하는 것 같지만(사이트에 액세스할 수 있음) 정적 리소스에 대한 각 요청은 404를 반환합니다. 각 요청은 docker ProxyPass 지시문을 사용하는 것처럼 보입니다(순서에 관계없이: 해당 지시어를 넣으면 마지막(아래 참조)은 여전히 ​​사용되는 유일한 것입니다.

이것은 생성된 로그 파일의 일부입니다.

yotter.domain.tld - - [12/Aug/2021:21:14:21 +0200] "GET /static/favicons/favicon.ico HTTP/1.1" 404 1935 file=proxy:http://127.0.0.1:5000/static/favicons/favicon.ico
yotter.domain.tld - - [12/Aug/2021:21:15:54 +0200] "GET /index HTTP/1.1" 200 1126 file=proxy:http://127.0.0.1:5000/index
yotter.domain.tld - - [12/Aug/2021:21:15:54 +0200] "GET /static/semantic/semantic.min.css HTTP/1.1" 404 1935 file=proxy:http://127.0.0.1:5000/static/semantic/semantic.min.css

그 이유는 무엇입니까?

이것은 nginx 구성입니다.

server {
    listen 80;
    server_name <example.com>; # ChangeME
    access_log off;

    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
    }

    location /static/ {
        root /home/ubuntu/Yotter/app/; # Change this depending on where you clone Yotter
        sendfile on;
        aio threads=default;
    }

    location ~ (^/videoplayback$|/videoplayback/|/vi/|/a/) {
        proxy_pass http://unix:/var/run/ytproxy/http-proxy.sock;
        add_header Access-Control-Allow-Origin *;
        sendfile on;
        tcp_nopush on;
        aio_write on;
        aio threads=default;
        directio 512;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
    }
}

그리고 지금까지 내가 가진 것은 다음과 같습니다.

<VirtualHost *:443>
        ServerName yotter.domain.tld

        LogFormat "%v %l %u %t \"%r\" %>s %b file=%f" commonvhost
        CustomLog ${APACHE_LOG_DIR}/yotter_access.log commonvhost

        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/domain.tld/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld/privkey.pem

        <Location "/">
                ProxyPass http://127.0.0.1:5000/
                ProxyPassReverse http://127.0.0.1:5000/
        </Location>


        <Location "/static">
                Alias "/var/www/Yotter/app/static"
        </Location>

        <Directory "/var/www/Yotter/app/">
                Require all granted
        </Directory>


        <LocationMatch (^/videoplayback$|/videoplayback/|/vi/|/a/)>
                ProxyPass unix:///var/run/ytproxy/http-proxy.sock
                ProxyPassReverse unix:///var/run/ytproxy/http-proxy.sock
                Header add Acces-Control-Allow-Origin: *
        </LocationMatch>

</VirtualHost>

또는

<VirtualHost *:443>
        ServerName yotter.domain.tld

        LogFormat "%v %l %u %t \"%r\" %>s %b file=%f" commonvhost
        CustomLog ${APACHE_LOG_DIR}/yotter_access.log commonvhost

        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/domain.tld/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld/privkey.pem


        Alias "/static" "/var/www/Yotter/app/static"

        <Directory "/var/www/Yotter/app/">
                Require all granted
        </Directory>


        <LocationMatch (^/videoplayback$|/videoplayback/|/vi/|/a/)>
                ProxyPass unix:///var/run/ytproxy/http-proxy.sock
                ProxyPassReverse unix:///var/run/ytproxy/http-proxy.sock
                Header add Acces-Control-Allow-Origin: *
        </LocationMatch>


        ProxyPass / http://127.0.0.1:5000/
        ProxyPassReverse / http://127.0.0.1:5000/

</VirtualHost>

답변1

다음을 사용하여 프록시에서 정적을 제외해야 합니다 !.

ProxyPass "/static" "!"

이는 구성의 프록시 명령 앞에 나타나야 합니다.

또는:

<Location "/static">
    ProxyPass "!"
</Location>

또한보십시오ProxyPass 공식 문서.

관련 정보