Nginx proxy settings

Time:2021-7-28

Generate kibana’s access account

Generate a password

openssl passwd '123456'

Create a htpasswd config in the container, with the user name in front and the password generated above in the back

user1:Iv64DdYe3QxLg

Create nginx profile

Next, create an nginx configuration file, default.conf

#Kibana panel
server {
    listen 80;
    server_name kibana.example.com;
    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://kibana:5601;
        auth_ Basic "login verification";
        auth_basic_user_file /htpasswd;
    }
}
#External access to file storage
server {
    listen 80;
    server_name storage.example.com;
    location / {
        proxy_set_header Host $http_host;
        proxy_pass http://minio:9000;
    }
}
#Main website
server {
    listen 80;
    server_name www.example.com;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    location /user-center/ {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://user-center:9501/;
    }
    location /storage/ {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://storage/;
    }
}

Create service

docker service create \
    --name nginx \
    --replicas 1 \
    --network my-net \
    -p 80:80 \
    --config source=default.conf,target=/etc/nginx/conf.d/default.conf \
    --config htpasswd \
     nginx:1.17.6-alpine

Next, you only need to resolve the domain name to any node IP

PHP microservice training series indexBlog: PHP micro service training series tutorial

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]