拟机搭建的ngnix和vsftpd的问题

Only_Joe 发布于 2016/11/26 21:45
阅读 276
收藏 0
虚拟机搭建的ngnix 和 vsftpd服务器物理机浏览器不能访问。
主机电脑通过ftp工具能访问。但是上传的图片物理机浏览器不能访问。

搭建ngnix 和vsftpd服务器 用来供主机做图片服务器使用。

使用filezilla 和自己的电脑都能下载访问。但是浏览器上不能访问,因为要用做图片服务器。如果访问不了就不知道怎么办了。


新手学习。请高人指点!

加载中
0
Feng_Yu
Feng_Yu
你也把你的nginx配置文件贴出来啊
Only_Joe
Only_Joe
配置信息在下面
0
大盘
大盘
nginx的路径对不对 ??还有文件的权限
Only_Joe
Only_Joe
配置信息在下面。
0
Only_Joe
Only_Joe

这是nginx.conf

[root@localhost ~]# cd /usr/local/nginx/conf
[root@localhost conf]# cat 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       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        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;
    #    }
    #}

}



0
Only_Joe
Only_Joe

nginx 能正常访问

0
Only_Joe
Only_Joe

这是防火墙配置文件

[root@localhost conf]# cat /etc/sysconfig/iptables
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 30000:30999 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@localhost conf]#



这是selinux
[root@localhost conf]# getsebool -a | grep ftp 
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> on
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off
[root@localhost conf]#

ftp_home_dir --> on修改了。


0
Only_Joe
Only_Joe
问题就是我的filezalli能访问我的图片服务器。但是浏览器访问http://192.168.40.131/images/1.jpg 访问不了。这里的www目录是浏览器访问的默认目录吗?我这里不知道怎么回事。
0
Feng_Yu
Feng_Yu

我知道为啥了,你的nginx是在sbin目录下启动的,root配置的是html,所以实际上nginx是从sbin/html下面去找静态资源去了。

建议你把root指令改为绝对路径,如root /var/www/html


Only_Joe
Only_Joe
非常感谢你的解答。问题就出来路径的问题。灰常感谢。
0
Only_Joe
Only_Joe

引用来自“Feng_Yu”的评论

我知道为啥了,你的nginx是在sbin目录下启动的,root配置的是html,所以实际上nginx是从sbin/html下面去找静态资源去了。

建议你把root指令改为绝对路径,如root /var/www/html



其中的root  后面改为/home/www;后还是不能访问。怎么办呢

应该改为什么呢


server {
        listen       80;
        server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {
            root   /home/www;
            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           /home/www;
            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;
        #}
    }



Feng_Yu
Feng_Yu
你的截图显示你的图片根本就不在/home/www下,你的ftp不是上传到/home/ftpuser/www/ 吗?那你的root应该是/home/ftpuser/www/。 最后确保你的nginx使用的用户能访问到/home/ftpuser/www/。把目录权限看看,再看看日志文件的报错
返回顶部
顶部