使用Nginx搭建图片服务器(windows环境下)

 更新时间:2018年06月27日 11:38:06   作者:shuaiflying  
这篇文章主要介绍了使用Nginx搭建图片服务器(windows环境下),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

知识点:在windows系统中,搭建图片上传服务器

1.进入官网下载nginx压缩包,解压后目录如下

2.在解压后的conf/nginx.conf配置文件中,添加添加或者修改带有颜色地方的代码

#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 G:/images/;#指定图片存放路径 
access_log G:/images/log;#图片路径 
proxy_store on; 
proxy_store_access user:rw group:rw all:rw; 
proxy_temp_path G:/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://169.254.140.133: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;
# }
#}
}

3.点击绿色的nginx.exe图标,启动服务器,在任务管理器看到如下,则启动成功

4.在浏览器中输入http://127.0.0.1:8089可以看到

5.在G:/images/下,放一个图片,在浏览器地址栏输入http://127.0.0.1:8089/img.jpg,就可以访问到服务器上的图片

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • 添加Nginx代理配置只允许内部IP访问的实现方法

    添加Nginx代理配置只允许内部IP访问的实现方法

    在本篇文章里小编给大家整理的是一篇关于添加Nginx代理配置只允许内部IP访问的实现方法的文章,有需要的朋友们可以学习下。
    2019-10-10
  • Nginx代理Partainer的具体使用

    Nginx代理Partainer的具体使用

    本文主要介绍了Nginx代理Partainer的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-03-03
  • Nginx+Keepalived实现双机主备的方法

    Nginx+Keepalived实现双机主备的方法

    这篇文章主要介绍了Nginx+Keepalived实现双机主备的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-03-03
  • Nginx实现if多重判断配置方法示例

    Nginx实现if多重判断配置方法示例

    这篇文章主要介绍了Nginx实现if多重判断配置方法示例,本文直接给出实现代码,需要的朋友可以参考下
    2015-05-05
  • 关于nginx 实现jira反向代理的问题

    关于nginx 实现jira反向代理的问题

    这篇文章主要介绍了关于nginx 实现jira反向代理的问题,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-09-09
  • 详解Nginx配置文件

    详解Nginx配置文件

    Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的,Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。这篇文章主要介绍了Nginx配置文件,需要的朋友参考下
    2017-01-01
  • nginx部署到服务器后文件上传提示405

    nginx部署到服务器后文件上传提示405

    使用nginx部署到服务器后,本地访问服务器地址,上传文件提示:405 Not Allowed,本文就来解决一下该问题,感兴趣的可以了解一下
    2023-10-10
  • 高并发nginx服务器的linux内核优化配置讲解

    高并发nginx服务器的linux内核优化配置讲解

    今天小编就为大家分享一篇关于高并发nginx服务器的linux内核优化配置讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
    2019-03-03
  • Nginx配置文件nginx.conf的基本配置实例详解

    Nginx配置文件nginx.conf的基本配置实例详解

    Nginx(engine x)是一个轻量级的高性能的HTTP和反向代理web服务器及电子邮件(IMAP/POP3)代理服务器,下面这篇文章主要给大家介绍了关于Nginx配置文件nginx.conf基本配置的相关资料,需要的朋友可以参考下
    2022-09-09
  • 在nginx中部署https服务的详细步骤

    在nginx中部署https服务的详细步骤

    Web服务器一般指网站服务器,可以处理浏览器等Web客户端的请求并返回相应响应,也可以放置网站文件,让全世界浏览;可以放置数据文件,让全世界下载,本文主要介绍nginx中部署https服务的具体流程,也是搭建web的开端与主要步骤之一
    2023-10-10

最新评论