RT,是 ingress-nginx 本身就是这样,还是说有相关配置可以更改。
以下是 nginx 相关配置:
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#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 /usr/share/nginx/html;
}
location = /hostname.html {
alias /etc/hostname;
}
# 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;
#}
}
1
halfcrazy 2020-10-05 01:45:00 +08:00 1
取决你的 ingress 的配置。ingress 里配了 host,那么访问必须带 houst 。没配 host 的话,域名 ip 都可以
|
2
oneoyn 2020-10-05 08:51:00 +08:00 via Android
sendfile on;
|
3
Cyshall OP @halfcrazy 感谢,但是我很奇怪阿,域名访问的第一步不就是查询域名对应的 IP 然后使用 IP 访问吗?这边 ingress 是咋做到这个限制的阿。
|
4
bowser1701 2020-10-05 09:57:27 +08:00 via iPhone 1
@Cyshall 根据 header 里面的 host 转发。
|