使用ubuntu安装的,直接apt install安装的,然后安装目录是在/etc/nginx,下面有一个nginx.conf的配置文件,我在http{}里面配置了server了,具体如下
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;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://180.101.49.11;
index index.html index.htm index.jsp;
}
}
}
重点在这几行:
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://180.101.49.11;
index index.html index.htm index.jsp;
}
}
这几行的含义不就是通过访问本地端口80之后再跳转到http://180.101.49.11这个ip地址吗,我试了试不行,访问80端口还是欢迎nginx的界面,所以我想问,是我配置出错了还是怎么回事,谢谢大佬们。