Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Nginx change the access path of static files?

Shulou Source: shulou.com Published: 2022-06-03 05:34:46 10月27日 Update

The Web service for external network users to access the server is provided by Nginx. Nginx needs to configure the path information of static resources in order to correctly access static resources on the server through url.

Open the default profile for Nginx

Vim / usr/local/nginx/conf/nginx.conf

Add the following configuration to service

Root static file root path

Sample code: / etc/nginx/nginx.conf

User nobody nobody;worker_processes 2 http errorists log / usr/local/nginx/logs/nginx_error.log crit;pid / usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200 leading events {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 6000;} http {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096 Log_format combined_realip'$remote_addr $http_x_forwarded_for [$time_local]'$host "$request_uri" $status''"$http_referer"$http_user_agent"; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k Request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path / usr/local/nginx/client_body_temp; proxy_temp_path / usr/local/nginx/proxy_temp; fastcgi_temp_path / usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on Gzip_min_length 1k; gzip_buffers 48k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml Server {listen 80 default; server_name _; root / var/ftp/source;} include / usr/local/nginx/conf/host/*.conf;}

Reload Nginx using the following command

. / nginx-s reload

When accessing through IP and port 80 again, the root path is the set path, and the static files can still be accessed by the paths of different static files.

Tags: Path static file service configuration server resource different code information again command user example port Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS Xiaomi Shulou Information vpn