首页 > 系统相关 >nginx配置图片服务器

nginx配置图片服务器

时间:2023-06-05 11:46:59浏览次数:103  
标签:index log server nginx html proxy 服务器 图片

start nginx                      //运行nginx

 nginx -s stop          // 停止nginx

nginx -s reload       // 重新加载配置文件(如修改配置文件后,可通过该命令重新加载)

nginx -s quit          // 退出nginx

nginx -v                 //可查nginx版本

#user  nobody;  
worker_processes  1;  
  
#error_log  logs/error.log;  
#error_log  logs/error.log  notice;  
#error_log  logs/error.log  info;  
  
#pid        logs/nginx.pid;  
  
  
events {  
    worker_connections  1024;  
}  
  
  
http {  
    include       mime.types;  
    default_type  application/octet-stream;  
  
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '  
                      '$status $body_bytes_sent "$http_referer" '  
                      '"$http_user_agent" "$http_x_forwarded_for"';  
  
    access_log  logs/access.log  main;  
  
    sendfile        on;  
    #tcp_nopush     on;  
  
    #keepalive_timeout  0;  
    keepalive_timeout  65;  
  
    #gzip  on;  
  
  
    server {  
        listen       8089;#端口号  
        server_name  localhost;#本机  
  
        charset utf-8;  
  
        #access_log  logs/host.access.log  main;  
  
    location ~ .*\.(gif|jpg|jpeg|png)$ {  
        expires 24h;  
            root D:/resourcesfile/images/;#指定图片存放路径  
            access_log D:/tools/nginx-1.6.1/logs/log_test.log;#图片路径  
            proxy_store on;  
            proxy_store_access user:rw group:rw all:rw;  
            proxy_temp_path         D:/resourcesfile/images/;#图片路径  
            proxy_redirect          off;  
  
            proxy_set_header        Host 127.0.0.1;  
            proxy_set_header        X-Real-IP $remote_addr;  
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;  
            client_max_body_size    10m;  
            client_body_buffer_size 1280k;  
            proxy_connect_timeout   900;  
            proxy_send_timeout      900;  
            proxy_read_timeout      900;  
            proxy_buffer_size       40k;  
            proxy_buffers           40 320k;  
            proxy_busy_buffers_size 640k;  
            proxy_temp_file_write_size 640k;  
            if ( !-e $request_filename)  
            {  
                 proxy_pass  http://127.0.0.1:8089;#代理访问地址  
            }  
    }    
  
        location / {  
            root   html;  
            index  index.html index.htm;  
  
        }  
  
        error_page  404              /404.html;  
  
        # redirect server error pages to the static page /50x.html  
        #  
        error_page   500 502 503 504  /50x.html;  
location = /50x.html {  
            root   html;  
        }  
  
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80  
        #  
        #location ~ \.php$ {  
        #    proxy_pass   http://127.0.0.1;  
        #}  
  
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
        #  
        #location ~ \.php$ {  
        #    root           html;  
        #    fastcgi_pass   127.0.0.1:9000;  
        #    fastcgi_index  index.php;  
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
        #    include        fastcgi_params;  
        #}  
  
        # deny access to .htaccess files, if Apache's document root  
        # concurs with nginx's one  
        #  
        #location ~ /\.ht {  
        #    deny  all;  
        #}  
    }  
  
  
    # another virtual host using mix of IP-, name-, and port-based configuration  
    #  
    #server {  
    #    listen       8000;  
    #    listen       somename:8080;  
    #    server_name  somename  alias  another.alias;  
  
    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  
  
  
    # HTTPS server  
    #  
    #server {  
    #    listen       443 ssl;  
    #    server_name  localhost;  
  
    #    ssl_certificate      cert.pem;  
    #    ssl_certificate_key  cert.key;  
  
    #    ssl_session_cache    shared:SSL:1m;  
    #    ssl_session_timeout  5m;  
  
    #    ssl_ciphers  HIGH:!aNULL:!MD5;  
    #    ssl_prefer_server_ciphers  on;  
  
    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  
  
}

配置完后,执行reload命令重新加载配置文件。然后进行访问图片,http://127.0.0.1:8089/036367.png 

标签:index,log,server,nginx,html,proxy,服务器,图片
From: https://www.cnblogs.com/netcore-vue/p/17457377.html

相关文章

  • 通过图片流来返回图片
    通过图片流来返回图片前言之前写了个图片接口,然后做了个授权,但是光返回图片地址虽然能适应大部分需求,但是考虑到有些人不想去处理返回值,也是做了个直接返回图片流的接口。接口展示返回指定宽度和高度图片流直接返回原图接口实现Service层如何返回图片流给前端呢,首先写个......
  • 轻量应用服务器和云服务器哪个更好?有什么区别?45.125.46.x
       做应用开发和网站建设的朋友在选择服务器配置时可能会遇到一个问题,轻量应用服务器与云服务器有什么不同之处?哪款服务器更好?今天微微来给你分享一下第一、配置区别我们可以看到,轻量服务器带宽是比云服务器大的,比如腾讯云,轻量服务器是5M带宽、云服务器是1M带宽,但是前者是1000......
  • Linux中DNS服务器的搭建
    1.DNS服务的安装2.配置主配置文件named.conf3.配置扩展配置文件named.rfc1912.zones4.配置正向解析文件sdcet.cn.zone ......
  • Linux系统下Samba服务器的配置
    第1步:将目录/home/media设置为允许所有用户访问,但仅允许用户mary具有修改该目录的权限。其配置步骤简述如下。第2步:将目录/var/samba/student设置为只允许student组的成员访问,student组中有stu01、stu02·····stu05,共5个成员。配置步骤简述如下。第3步:用testparm命令测试......
  • Linux系统下NFS服务器的配置
    第1步:NFS规划。1)将本地文件系统的/home/mp3目录共享,mary客户机对该目录具有读写限权,其他所有用户对该目录具有只读限权。 2)将本地文件系统的/home/vedio目录共享,192.168.21.100与192.168.21.200两个客户机对该目录具有读写限权,而192.168.21.0、24网段内的其他客户机对该目录......
  • Andrid listview异步图片加载之优化篇
    关于listview的异步加载,网上其实很多示例了,总体思想差不多,不过很多版本或是有bug,或是有性能问题有待优化。有鉴于此,本人在网上找了个相对理想的版本并在此基础上进行改造,下面就让在下阐述其原理以探索个中奥秘,与诸君共赏…        贴张效果图先:         异步加载......
  • 基于Selenium库的python爬虫脚本,爬取painterest上的图片
    基于Selenium库的python爬虫脚本,爬取painterest上的图片问题背景Pinterest是一个社交媒体平台,它提供了一个虚拟的个人兴趣画板,让用户可以收集和分享他们喜欢的图片、视频和链接。上面有许多优秀的图片供浏览和下载,但是一个个点图片下载非常麻烦。于是想要用Python语言写一个自......
  • 使用 Nginx Upload Module 实现上传文件功能
    普通网站在实现文件上传功能的时候,一般是使用Python,Java等后端程序实现,比较麻烦。Nginx有一个Upload模块,可以非常简单的实现文件上传功能。此模块的原理是先把用户上传的文件保存到临时文件,然后在交由后台页面处理,并且把文件的原名,上传后的名称,文件类型,文件大小set到页面。下面和大......
  • 银河麒麟服务器V10 SP3 安装ZooKeeperZookeeper 图形化的客户端工具(ZooInspector)
    服务器zookeeper安装一、软件介绍1、ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。2、ZooKeeper的原理......
  • nginx开启更为安全的tls1.3
    随着互联网安全越来越受到重视,越来越多的网站选择启用https来保证数据的加密传输,TLS1.2发布于2008年8月,至今正好有10年,所以新协议TLS1.3呼之欲出。Googlechrome在最近的版本更新中也开始逐步对TLS1.3进行支持,TLS1.3对于TLS1.2有重大改写,提高了安全性并且提高了速度,所以升级还是很......