background
When I returned to my hometown, I found that Github network is limited, sometimes I can open it, but if I need to read the source code, it is very slow to download, and sometimes I can not download at all. I want to use Ali Cloud server to download, and local access to Ali cloud static resources can solve this problem. As for how to install it, I choose to use Docker, because I can be lazy. I will try to install it by source code compilation later, and I will update it after completion.
The installation
docker search nginx
docker pull nginx:lasted
Copy the code
configuration
#Create the host directory and test resource files
mkdir /usr/local/nginx/conf
mkdir /usr/local/nginx/log
mkdir /opt/download/
cd /opt/download/
touch test.txt
Copy the code
Then copy a configuration file from the Docker image
docker exec -it container_id /bin/bash
cd /etc/nginx
#You can see nginx.conf in the directory
#Copy nginx.conf to /usr/ on the host machinelocal/ nginx/conf
#Then switch back to the host to modify the configuration file
Copy the code
If you use localtion to configure /download, you can access static resources in the /opt/download/ directory. See my other post for configuration rulesNginx configuration file nginx.conf
Start the
docker run --name nginx9099 -d -p 9099:80 -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/nginx/log:/var/log/nginx -v /opt/download/:/opt/download/ nginx
Copy the code
– v/usr/local/nginx/conf/nginx. Conf: / etc/nginx/nginx. Conf will be hosting/usr/local/nginx/conf/nginx. Mount the conf file to the corresponding directory – v in the container / usr/local/nginx/log: / var/log/nginx in the same way, for the convenience of the host machine to check the log – v/opt/download / : / opt/download/will host machine mounted to the container corresponding to the directory of resources, in order to access
test
To view the resources in this directory, access the corresponding IP address :port/ Download /.