openstack shares instance code for ports 80 and 443
- 2020-10-23 20:21:37
- OfStack
preface
Since openstack USES apache, it is not possible to share port 80, but many of the cloud hosts created, although they can jump through rinetd, sometimes require direct access to port 80, so here we chose openrety, which includes nginx.
1.1. Installation openresty
1. Add openresty warehouse to centos system
#yum install yum-utils
#yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
2. Install the package
#yum install openresty
3. Install the command line tools
#yum install openresty-resty
1.2. The configuration openresty
1. Enter the nginx directory
#cd /usr/local/openresty/nginx/conf/
2. Edit the nginx profile
#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 The domain name ;
# Specify log path
access_log logs/access.log main;
error_log logs/error.log;
#
location / {
proxy_pass http://172.17.17.113;
}
}
}
3. Create the conf.d folder in the current directory
#mkdir /usr/local/openresty/nginx/conf/conf.d
#cd conf.d
4. Create the files to be read, currently defined as 1 per machine, here defined as adding 1 aa machine, then create ES41en.conf.
#vi aa.conf
server {
listen 80;
# The binding https include /usr/local/openresty/nginx/https/https.conf;
# Binding domain
server_name The domain name ;
# Specify log path
access_log logs/ope.access.log main;
error_log logs/ope.error.log;
# Specifies a jump port through the domain name
location / {
proxy_pass http://172.17.17.136:8081;
}
}
1.3. Use openresty
1. Check whether nginx is configured correctly
#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. Overloaded openresty
#openresty -s reload
3. Verify
Enter the bound domain name in your browser to access 80 or the desired port directly.