我正在尝试为打包服务(npm 和 bower.io)设置代理服务,并且我想在本地缓存包。
我的 Apache 配置:
Listen 127.0.0.1:10010
Listen 127.0.0.1:10011
<VirtualHost 127.0.0.1:10011>
ProxyRequests On
SSLEngine On
ServerName 127.0.0.1:10011
SSLProtocol All
SSLCertificateFile /opt/npm-cache/certs/npmcache.crt
SSLCertificateKeyFile /opt/npm-cache/certs/npmcache.key
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
CacheRoot /opt/npm-cache/data/ssl
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
CacheDefaultExpire 2628000
ErrorLog /opt/npm-cache/logs/ssl-error.log
CustomLog /opt/npm-cache/logs/ssl-custom.log common
TransferLog /opt/npm-cache/logs/ssl-transfer.log
</VirtualHost>
<VirtualHost 127.0.0.1:10010>
ServerName 127.0.0.1:10010
ProxyRequests On
CacheRoot /opt/npm-cache/data/non-ssl
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
CacheDefaultExpire 2628000
ErrorLog /opt/npm-cache/logs/error.log
CustomLog /opt/npm-cache/logs/custom.log common
TransferLog /opt/npm-cache/logs/transfer.log
</VirtualHost>
这不起作用。我在日志中看到的问题:
[Mon Jan 27 14:15:01 2014] [info] [client 127.0.0.1] (70014)End of file found: SSL input filter read failed.
[Mon Jan 27 14:15:01 2014] [info] [client 127.0.0.1] Connection closed to child 4 with standard shutdown (server 127.0.0.1:10011)
我的服务器的证书是自签名的。
答案1
我建议您为此目的使用 nginx,因为它是一个更好的缓存服务器。
nginx 的配置如下:
server {
listen 443;
server_name www.npmpackages.com;
access_log /var/log/nginx/npmpackages-ssl.access.log;
ssl on;
ssl_certificate ssl/npmpackages_com.bundle.crt;
ssl_certificate_key ssl/npmpackages_com.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:-LOW:+SSLv3:-EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://www.npmpackages.com;
proxy_cache on;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}