Before installation, you first need to create a Docker container named `nginx-container`, map port 80 of the host to port 80 of the container, and change the local `nginx.conf `Mount the file into the configuration file in the container to achieve overwriting of the configuration file. At the same time, the log file will be mounted to the `/home/docker-nginx/log/` directory of the host machine to facilitate log management. Use the `-d` parameter when starting the container to run in background mode.
Static resource deployment can be achieved by storing files in the `~/nginx/html` directory, so that static resources can be accessed by directly accessing the directory in the browser.
You can use the `vim` editor to add custom configurations to the configuration file. For example, to configure independent ports for each project, use the `static.conf` file for port binding.
When binding a domain name, the corresponding domain name needs to be resolved to the IP address of the container. The reverse proxy function is used to forward client requests to back-end servers, such as Tomcat, to achieve load balancing.
When configuring load balancing, you can define the backend server group by setting the `upstream` block, such as `upstreamtomcat-kkb`. Specify each server and its corresponding weight in this block. The larger the weight value, the higher the priority. For example, set the weights of two servers to 2 and 1 respectively.
To solve the front-end AJAX cross-domain problem, you usually need to add instructions such as `proxy_pass` and `proxy_set_header` in the Nginx configuration file to achieve cross-domain resource sharing (CORS).
For HTTPS configuration, you need to pre pare the SSL certificate and configuration file, and use the `ssl` directive to configure the SSL listening port and certificate path in `nginx.conf`. Make sure all HTTPS-related configurations are correct for secure web access. Deploy nginx in docker environment