Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The running nginx of the "intermediate article" docker jumps to the local jar and configures the https (80)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Original articles, welcome to reprint. Reprint please indicate: Reprint from IT people story meeting, thank you!

The original link address: "intermediate article" docker run nginx jump to the local jar and configure https (outside article)(80)

The real environment, a 1 core 2g memory, installed mysql container, java container, nginx container. I won't say the specific installation of docker, there is nothing to say repeated many times. MySQL has also been mentioned before.

Installation of nginx

New directory for nginx

nginx

Prevent the following errors

docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused "rootfs_linux.go:57: mounting \"/root/conf/nginx/nginx.conf\" to rootfs \"/var/lib/docker/aufs/mnt/edd3b9a8923f13404d42aa73f509b625c7370791c825424427eacae6432fecc8\" at \"/var/lib/docker/aufs/mnt/edd3b9a8923f13404d42aa73f509b625c7370791c825424427eacae6432fecc8/etc/nginx/nginx.conf\" caused \"not a directo! [](http://upload-images.jianshu.io/upload_images/11223715-3407e1c7ac8d7935? imageMogr2/auto-orient/strip|imageView2/2/w/1240)ry\""": Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

Make sure the folder exists

touch conf/nginx.confecho 1 > conf/nginx.conf

create a container

docker run -d -p 80:80 \--name five-nginx \-p 443:443 \-v /home/user/nginx/cert:/etc/nginx/cert \-v /home/user/nginx/config/nginx.conf:/etc/nginx/nginx.conf \-v /home/user/nginx/html:/usr/share/nginx/html \-v /home/user/nginx/log:/var/log/nginx \hub.c.163.com/library/nginx configuring nginx files

#user nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; server { listen 80; server_name www.abc.xyz; rewrite ^ https://$http_host$request_uri? permanent; } server { listen 443; server_name www.abc.xyz; ssl on; ssl_certificate /etc/nginx/cert/www.idig8.xyz.crt; ssl_certificate_key /etc/nginx/cert/www.idig8.xyz.key; ssl_session_timeout 5m; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://172.17.0.3:8888/; proxy_redirect off; } }}

Java project started using port 8888

nginx proxy_pass configuration cannot be used 127.0.0.1:8888

You must use the ip address inside the java container http://172.17.0.3:8888/; it can be viewed via docker inspect.

https configuration

Put the crt, key downloaded from cert aliyun into the specified directory cert.

PS: Basic nginx container configuration key and key, jump back, access java container IP.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report