博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos安装nginx并且配置域名访问rancher
阅读量:2064 次
发布时间:2019-04-29

本文共 2965 字,大约阅读时间需要 9 分钟。

安装nginx

首先我们需要使用root用户进行操作

第一步:添加nginx存储库

使用命令:

sudo yum install epel-release

(我这里已经添加过了。。。)

第二步:安装nginx

使用yum安装,使用命令

sudo yum install nginx

在对提示回答yes后,Nginx将在服务器上完成安装。安装成功如图:

第三步:启动nginx

安装成功之后启动nginx,使用命令

sudo systemctl start nginx

启动后没有任何的日志打印。。。就OK了

第四步:验证nginx是否启动成功

首先可以查看后台是否启动,使用命令

ps -ef |grep nginx

。如下图所示就成功了!

其次用浏览器访问一下 ip:80 ,见如下图,即成功了

如果想在系统启动的时候,nginx就启动的话可以使用命令
sudo systemctl enable nginx
nginx启动命令也可是切换到nginx/sbin目录下面使用./nginx进行启动
重启命令
./nginx -s reload
第四步:配置域名访问rancher

域名设置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

你可能感兴趣的文章
C#在Excel中将连续多列相同数据项合并
查看>>
C#如何把html中的相对路径变成绝对路径
查看>>
用C#编写发手机中文短信息Windows服务
查看>>
C#的四个基本技巧
查看>>
编程实例 使用C#的BitmapData
查看>>
区分Oracle和SQL Server常用函数调用方法
查看>>
详解Visual C#数据库基本编程
查看>>
第一个C#应用程序
查看>>
第一章C#简介
查看>>
NGWS runtime 技术基础
查看>>
Linux find 文件查询 用法示例
查看>>
Linux 查看文件大小
查看>>
mysql 命令
查看>>
MySQL执行外部sql脚本文件的命令
查看>>
解决MySql Error Code: 2006
查看>>
查看mysql数据库和表所占用空间
查看>>
Guava Collections使用介绍
查看>>
Ordering犀利的比较器
查看>>
spring+Mybatis+Ehcache整合
查看>>
google guava使用例子/示范(一)
查看>>