nginx的配置如下,为啥下面两个地址匹配不出来?

访问地址1:http://110.42.139.52:12345/a/b
返回图片1,为什么截图中的路径携带了/a/b?
访问地址2:http://110.42.139.52:12345/b
返回图片2,location /不是通用匹配吗,不是任何请求都可以匹配到吗?

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '

# '$status $body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 12345;

server_name 110.42.139.52;

#charset koi8-r;

#access_log logs/host.access.log main;

location /{

proxy_pass http://www.baidu.com;

}

location /a {

proxy_pass http://www.163.com;

}

location /a/b {

proxy_pass http://www.126.com;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

#location ~ \.php$ {

# root html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

# deny all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

# listen 8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location / {

# root html;

# index index.html index.htm;

# }

#}

# HTTPS server

#

#server {

# listen 443 ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}


回答:

proxy_pass 不应该显示原地址

可以看到百度的 icon,其实就是成功了,404 是百度服务器返回的。你可以使用这个测试http://110.42.139.52:12345/s?wd=sf

以上是 nginx的配置如下,为啥下面两个地址匹配不出来? 的全部内容, 来源链接: utcz.com/p/944293.html

回到顶部