Nginx 在加载图像时仍然要求输入密码
Nginx Still Asking For Password When Loading Images
我有问题,我已经为我的 rails 后端站点设置了 nginx 身份验证,我正在使用 self.user 和 self.password, 一切正常,但是当它加载图像时,后端站点仍然要求用户名和登录。
知道如何解决这个问题吗?
Nginx 配置:
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 站点配置:
server {
listen 80;
listen [::]:80;
server_name servername.com;
passenger_enabled on;
passenger_friendly_error_pages on;
passenger_ruby /home/deploy/.rvm/gems/ruby-2.3.1/wrappers/ruby;
rails_env production;
root /home/deploy/project_name/current/public/;
location / {
passenger_enabled on;
auth_basic "Authorization Required";
auth_basic_user_file /etc/nginx/.htpasswd;
}
我通过为图像文件添加例外解决了这个问题。
location ~* \.(jpe?g|png|gif|ico)$ {
satisfy any;
auth_basic off;
}
我有问题,我已经为我的 rails 后端站点设置了 nginx 身份验证,我正在使用 self.user 和 self.password, 一切正常,但是当它加载图像时,后端站点仍然要求用户名和登录。
知道如何解决这个问题吗?
Nginx 配置:
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx 站点配置:
server {
listen 80;
listen [::]:80;
server_name servername.com;
passenger_enabled on;
passenger_friendly_error_pages on;
passenger_ruby /home/deploy/.rvm/gems/ruby-2.3.1/wrappers/ruby;
rails_env production;
root /home/deploy/project_name/current/public/;
location / {
passenger_enabled on;
auth_basic "Authorization Required";
auth_basic_user_file /etc/nginx/.htpasswd;
}
我通过为图像文件添加例外解决了这个问题。
location ~* \.(jpe?g|png|gif|ico)$ {
satisfy any;
auth_basic off;
}