小编在学习nginx反向代理的时候,教学的环境是linux操作化境,所以在配置环境和操作配置文件的时候,有许多不一样的地方,nginx.conf文件中是没有server字段的。那么它们到哪里去了呢?
环境:docker操作镜像
1)、非docker镜像(windows目录下)
1.在nginx目录中,配置修改在nginx.conf中
2.nginx.conf内置结构
3.全部目录
2)、nginx容器
1.进入容器查看nginx目录
2.查看nginx内部目录
3.查看nginx.conf文件内容
root@69ec34b17d41:/etc/nginx# cat 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;
}
注意:nginx.conf中并没有server这一标签栏,那么server标签栏在哪里呢?小编也是找了许久,最后发现是在conf.d中的default.conf配置文件中
4.进入conf.d目录下,查看default.conf文件
root@69ec34b17d41:/etc/nginx# cd conf.d
root@69ec34b17d41:/etc/nginx/conf.d# ls
default.conf
root@69ec34b17d41:/etc/nginx/conf.d# cat 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;
}
# 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;
#}
}
3)、反向代理
1.具名挂载在本地目录
1.nginx mNG_Twi
2.tomcat 8080 mTM03
3.tomcat 8081 mTM04
2.容器列表
3.访问测试服务器
4.配置conf.d文件
5.分别给tomcat目录添加one和two文件夹
6.请求测试
好了,关于反向代理就讲这么多了,小编会继续研究容器中的配置文件的~