preface

Recently, I had such a requirement in my work: the machine on which we deployed services for customers could not access the Internet, so one of our services could not pull public network picture resources. To verify the connectivity of the entire service process, only one file server can be deployed on the target machine to test the entire service instead of public network resources.

Deploy the nginx file server

Install nginx offline

  1. Download the Nginx installation package on your networked machine.
  2. Copy the installation package to the target server, install nginx,dpkg -i nginx_xxx.deb.
  3. To view the nginx installation path,whereis nginx.
  4. Start the nginx.

Modifying a Configuration File

Conf files in the conf.d folder will be automatically imported into the configuration file, so we create a new file_server.conf configuration file in the conf.d folder.

server {
  listen 80; Note if the port is occupied
  server_name localhost; Select the host name
  root /home/file; # Directory for storing files on the file server
  location / {
    autoindex on; # display index
    autoindex_exact_size on; # display size
    autoindex_localtime on; # display time
    charset utf-8; # Avoid Chinese garbled characters}}Copy the code

You need to delete the nginx default configuration: cp/etc/nginx/conf. D/default. Conf/etc/nginx/conf. D/default. Conf. Bak. To start the nginx service: /etc/init.d/nginx start

Testing the file Server

  1. Copy local images to the file server.
  2. View the Intranet address of the server:hostname -I.
  3. Access image links from Intranet addresses:http://10.10.100.100/xxx.jpg.