由於openstack使用的是apache,因此不能共享80端口,但建立的許多雲主機,雖然能夠經過rinetd進行跳轉,但有時須要直接訪問80端口,因此這裏咱們選擇包含了nginx的openrety。nginx
1.向centos系統中添加openresty倉庫apache
#yum install yum-utils #yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
2.安裝軟件包centos
#yum install openresty
3.安裝命令行工具瀏覽器
#yum install openresty-resty
1.進入nginx目錄app
#cd /usr/local/openresty/nginx/conf/
2.編輯nginx配置文件tcp
#vi nginx.conf工具
user root; worker_processes 12; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;
#pid logs/nginx.pid; events { worker_connections 10240; } http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; include conf.d/*; server { listen 80;
# server_name 域名;
#指定日誌路徑 access_log logs/access.log main; error_log logs/error.log; # location / { proxy_pass http://172.17.17.113; } } }
3.在當前目錄下建立conf.d文件夾spa
#mkdir /usr/local/openresty/nginx/conf/conf.d
#cd conf.d
4.建立要被讀取的文件,目前定義爲每臺機器建立一臺,這裏定義添加一臺aa機器,則建立aa.conf。命令行
#vi aa.confrest
server {
listen 80;
#綁定https
include /usr/local/openresty/nginx/https/https.conf;
#綁定域名
server_name 域名;
#指定日誌路徑
access_log logs/ope.access.log main;
error_log logs/ope.error.log;
#指定經過域名跳轉端口
location / {
proxy_pass http://172.17.17.136:8081;
}
}
1.檢測nginx是否配置正確
#openresty -t nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
2.重載openresty
#openresty -s reload
3.驗證
在瀏覽器上輸入綁定的域名便可直接訪問80或者所需端口。