nginxはファイルサービスを提供しません

nginxはファイルサービスを提供しません

/var/wwwディレクトリを名前付きディレクトリにコピーしました。次に、そのディレクトリ()とそのシンボリックリンク()を指すように設定を設定するmysiteファイルを作成しました。sites-available/etc/nginx/sites-available/mysitesites-enabled/etc/nginx/sites-enabled/mysite

server {
    listen 4000 default_server;
    listen [::]:4000 default_server;

    root /var/www/otsui;

    index index.html;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

}

ただし、インポートしようとすると、サービスが提供されていないというページが表示さhttp://localhost:4000/れます。This site can’t be reached

nginxまた、サービスを再起動してみました。

Debian Jesse がいます。

私のファイアウォールは次のとおりです。

root@mylab:/var/www# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (2 references)
target     prot opt source               destination         

Chain DOCKER-ISOLATION (1 references)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            

また、私のウェブサイトファイルをデフォルトのディレクトリにコピーしてみました/var/www/html。つまり、サービスを再起動してもブラウザでナビゲートすると、http://127.0.0.1:3000/まだスタートページが表示されます。nginxnginx

ベストアンサー1

私は問題を解決しました。問題は、構成をロードするために含め/etc/nginx/sites-enabled/なかったことです。/etc/nginx/nginx.confサービスがrestartオンラインになった後、nginxWebアプリケーションが完全にデプロイされました。

nginx -t設定のすべての変更が正しいことを確認するためにコマンドの出力も確認したことに言及したいと思います。nginx成功した再構成の結果は次のとおりです。

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

ところで、これは私の現在のnginx設定です。

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

#    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

おすすめ記事