Nginx怎么改静态文件的访问路径?
admin
2023-02-05 16:40:03
0

外网用户访问服务器的 Web 服务由 Nginx 提供,Nginx 需要配置静态资源的路径信息才能通过 url 正确访问到服务器上的静态资源。
打开 Nginx 的默认配置文件

vim /usr/local/nginx/conf/nginx.conf

将service中添加如下配置

root 静态文件根路径

示例代码:/etc/nginx/nginx.conf

user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{   
    use epoll;
    worker_connections 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 4 8k;
    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;
}

使用以下命令,重新加载Nginx

./nginx -s reload

再次通过IP和80端口访问时是以设置好的路径为根路径,可以依旧不同静态文件的路径访问静态文件

相关内容

热门资讯

今日重大发现“蛮王牛牛可以开挂... 有 亲,根据资深记者爆料蛮王牛牛是可以开挂的,确实有挂(咨询软件无需打开...
终于懂了“云圈丰城麻将可以开挂... 网上科普关于“云圈丰城麻将有没有挂”话题很是火热,小编也是针对云圈丰城麻将作*弊开挂的方法以及开挂对...
阎学通:如果特朗普坚决拿下格陵... 新加坡《联合早报》1月12日报道,知名学者评估,如果特朗普坚决拿下格陵兰岛,美国跟欧洲国家在军控等各...
【今日要闻】“全民游戏有没有挂... 网上科普关于“全民游戏有没有挂”话题很是火热,小编也是针对全民游戏作*弊开挂的方法以及开挂对应的知识...
“古德之死”引爆全美上千场抗议 【环球时报驻美国特约记者 李准 环球时报特约记者 于文】当地时间10日至11日,美国数十座主要城市发...
【第一资讯】“八闽福建麻将真的... 【第一资讯】“八闽福建麻将真的有挂吗?”(果然有透视挂)您好,八闽福建麻将这个游戏其实有挂的,确实是...
终于懂了“闲逸斗地主开挂器?”... 网上科普关于“闲逸斗地主有没有挂”话题很是火热,小编也是针对闲逸斗地主作*弊开挂的方法以及开挂对应的...
【第一资讯】“同城乐吧开挂器?... 有 亲,根据资深记者爆料同城乐吧是可以开挂的,确实有挂(咨询软件无需打开...
今日重大消息“天酷牛牛开挂器?... 家人们!今天小编来为大家解答天酷牛牛透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
最新引进“欢聚斗地主怎么开挂?... 网上科普关于“欢聚斗地主有没有挂”话题很是火热,小编也是针对欢聚斗地主作*弊开挂的方法以及开挂对应的...