Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx modifies static file access path

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report