Add configuration to existing Nginx services using include import configuration, small intrusion, general purpose

1. In/app/New front-end project files are stored in the directory according to the project namewebapps

In 2./app/nginx/The front-end project is added to the directoryconfThe configuration directory

3. Add the project configuration file to the front-end conf configuration directory

Configuration file name:

Conf, for example, pc_slcl_web_8880.conf

Configuration file contents:

Location/SLCL {root /app/webapps/; index index.html index.htm; Error_log /app/nginx/logs/slcl-error.log error; Add_header access-control-allow-origin *; add_header Access-Control-Allow-Methods'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; # process OPTIONS requestsif ($request_method = 'OPTIONS') {
      return 204; }}Copy the code

4. Extend the Nginx configuration file

/app/nginx/conf/nginx.conf

  1. In the original configurationserverIn the newinclude /app/nginx/webapps_conf/*.conf;

5. Restart the nginx service and check whether the log output is normal

  1. Start command (available directly tonginx/sbinPerformed in) :/app/nginx/sbin/nginx -s reload