本文共 2965 字,大约阅读时间需要 9 分钟。
首先我们需要使用root用户进行操作
使用命令:
sudo yum install epel-release
(我这里已经添加过了。。。)
使用yum安装,使用命令
sudo yum install nginx
在对提示回答yes后,Nginx将在服务器上完成安装。安装成功如图:
安装成功之后启动nginx,使用命令
sudo systemctl start nginx
启动后没有任何的日志打印。。。就OK了
首先可以查看后台是否启动,使用命令
ps -ef |grep nginx
。如下图所示就成功了!
其次用浏览器访问一下 ip:80 ,见如下图,即成功了
sudo systemctl enable nginx
./nginx
进行启动./nginx -s reload
域名设置a记录指向主机
配置你nginx反向代理
nginx.conf配置:
user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;events { worker_connections 1024;}http { 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; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; proxy_headers_hash_bucket_size 1024; proxy_headers_hash_max_size 512; client_body_buffer_size 512k; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_buffer_size 32k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; map $http_upgrade $connection_upgrade { default Upgrade; '' close; } upstream rancher-server { server 127.0.0.1:8080; } include /etc/nginx/conf.d/rancher.conf; include /etc/nginx/conf.d/default.conf;}
rancher.conf 配置如下:
server { listen 80; server_name rancher.59et.com; #charset koi8-r; index index.html index.htm; access_log /var/log/nginx/rancher.access.log main; location / { proxy_pass http://rancher-server; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 900s; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
重新加载配置
nginx -s reload
查看效果:
至此,通过域名访问rancher控制台配置完成,下一节着重讲一下rancher配置测试环境和生产环境。做到环境隔离
参考资料:
https://www.jianshu.com/p/8a6d923cda9f
https://www.cnblogs.com/zhengqing/p/11256417.html
https://blog.csdn.net/ming2316780/article/details/86505549