트래픽을 내 백 엔드 서버에 전달하기 전에 기본 인증을 사용하여 역방향 프록시를 구성하려고합니다. 어느 누구도 해결책을 줄 수 있습니까? 여기기본 인증을 사용하는 Apache 역방향 프록시
예 :
사용자 (인터넷) -> 리버스 프록시 /의 가상 호스트 서버 (여기에서 기본 인증을 추가해야합니다) -> 백 엔드 서버 (비 인증)
트래픽을 내 백 엔드 서버에 전달하기 전에 기본 인증을 사용하여 역방향 프록시를 구성하려고합니다. 어느 누구도 해결책을 줄 수 있습니까? 여기기본 인증을 사용하는 Apache 역방향 프록시
예 :
사용자 (인터넷) -> 리버스 프록시 /의 가상 호스트 서버 (여기에서 기본 인증을 추가해야합니다) -> 백 엔드 서버 (비 인증)
현재의 지침을 따를 수 있습니다 : Authentication, Authorization 및 Access Control. 역방향 프록시의 주요 차이점은 워드 프로세서 그들은 단지 디렉토리 블록에서 사용할 수있는 말에도 불구하고 위치 블록 내부의 인증 물건을 넣을 것이다 : 위치 블록 외부
<Location />
AuthType Basic
...
</Location>
당신
ProxyPass/http://localhost:8080/
다음은 데이터베이스에 대한 https를 통한 기본 인증을 수행하는 데 사용한 설정입니다. 백엔드 서버가 Tomcat을 실행 중이고 AJP를 사용하여 연결합니다. 재미있는 포트 번호 (4443)는 표준 포트 (443)가 이미 사용 되었기 때문에 동일한 포트에 여러 개의 https 서비스를 구성하지 않기 때문입니다. 당신의 아파치가 그 다음 유틸 패키지
sudo apt-get install apache2-utils
이있는 경우
<IfModule mod_ssl.c>
NameVirtualHost *:4443
<VirtualHost *:4443>
ServerAdmin [email protected]
ServerName ws.myserver.se
ServerAlias ws.myserveralias.se
ErrorLog /var/log/apache2/ajpProxy.error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog /var/log/apache2/ajpProxy.log combined
DBDriver mysql
DBDParams "host=127.0.0.1 port=3306 user=proxyAuthUser pass=yourDbPasswordHere dbname=yourDbName"
DBDMin 4
DBDKeep 8
DBDMax 20
DBDExptime 300
<Proxy *>
# core authentication and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName "Backend auth name"
AuthBasicProvider dbd
# core authorization configuration
Require valid-user
# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery \
"SELECT password FROM user WHERE emailAddress = %s"
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass/ajp://localhost:8009/
ProxyPassReverse/ajp://localhost:8009/
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/ssl/yourCertificateFile.crt
SSLCertificateKeyFile /etc/apache2/ssl/yourPrivateKeyFile.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
첫째, 확인, 사용자 이름과 암호를 설정합니다.
sudo htpasswd -c /etc/apache2/.htpasswd <username>
그 후,
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass/http://someaddress:1234/
ProxyPassReverse/http://someaddress:1234/
Timeout 5400
ProxyTimeout 5400
ServerName dev.mydomain.com
ServerAlias *.dev.mydomain.com
<Proxy *>
Order deny,allow
Allow from all
Authtype Basic
Authname "Password Required"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Proxy>
</virtualhost>
이 적어도,
sudo service apache2 reload
그래, 그것도 리버스 프록시와 함께 작동 아파치 업데이트 인증을 사용하도록 역방향 프록시를 편집 할 수 있습니다. – lzap
[doc] (http://httpd.apache.org/docs/2.2/mod/directive-dict.html#Context)는이 컨텍스트에서 작동 함을 나타냅니다. "디렉토리 이 컨텍스트에서 유효한 것으로 표시된 지시문은 구성 섹션에 설명 된 제한 사항에 따라, , 및 컨테이너를 서버 구성 파일에 사용할 수 있습니다." –
Pete