拟机搭建的ngnix和vsftpd的问题

发布于 2021-11-27 14:48:12 字数 644 浏览 693 评论 12

虚拟机搭建的ngnix 和 vsftpd服务器物理机浏览器不能访问。
主机电脑通过ftp工具能访问。但是上传的图片物理机浏览器不能访问。

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

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


新手学习。请高人指点!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

凌乱心跳 2021-12-03 16:16:01

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

清欢 2021-12-03 16:15:56

引用来自“Feng_Yu”的评论

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

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

后知后觉 2021-12-03 16:15:53

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

醉酒的小男人 2021-12-03 16:15:51

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

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

各自安好 2021-12-03 16:15:46

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

英雄似剑 2021-12-03 16:12:27

这是防火墙配置文件

[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修改了。

野心澎湃 2021-12-03 16:12:24

nginx 能正常访问

囚你心 2021-12-03 16:11:27

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

}

无人问我粥可暖 2021-12-03 16:09:43

配置信息在下面。

够钟 2021-12-03 13:57:03

nginx的路径对不对 ??还有文件的权限

伴我心暖 2021-12-03 13:38:37

配置信息在下面

筱武穆 2021-12-03 02:51:04

你也把你的nginx配置文件贴出来啊

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文