nginx安装在192.168.64.100上
图片1.png在192.168.64.102主机的路径为/tmp/images/1.png
现在需要使用image.xyz.com/images/1.png访问1.png这张图片
nginx.conf文件配置:
server {
listen 80;
server_name image.xyz.com;
location / {
}
}
哪位大神教教我server里面应该怎么配置呢?192.168.64.102主机还需要进一步配置吗?拜托
忘了说了 upstream + 代理名字 upstream模块中即指定反向代理的ip跟端口 对应你的应该写192.168.64.100+端口 ftp服务的话是21端口 web服务的话是80端口
1.192.168.64.102上需要一台webservice 或者ftp service 来应答你的文件请求
2.192.168.64.100 也就是你的nginx服务器 需要开启反向代理功能 将请求静态文件的请求分发到192.168.64.102上
3.nginx反向代理的配置很简单 以下是我的一段代理node.js的配置
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/error.log combined;
sendfile on;
keepalive_timeout 65;
gzip on;
upstream sample {
server 127.0.0.1:9000;
}
server{
listen 8080;
server_name www.node.com;
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass http://sample;
}
}
}
你需修改location后边 /代表所有类型的请求 假设你只想把png的分发出去 使用正则匹配 *.png即可
nginx配置文件中有用#注释的 里面就有匹配规则 如果你能给加上缓存 那样就更好了