【问题标题】:nginx not serving default mediagoblin on debian jessienginx 没有在 debian jessie 上提供默认的 mediagoblin
【发布时间】:2017-10-22 09:07:09
【问题描述】:

我整个周末都在努力解决这个问题……我已经放弃了谷歌搜索。我发现了类似的问题,但我找到的解决方案都没有解决这个问题。我对媒体妖精很陌生,之前还没有真正深入研究过 linux,所以我很菜鸟。

我已按照http://mediagoblin.readthedocs.io/en/stable/siteadmin/deploying.html 的说明保持所有默认设置,只是为了让默认设置正常工作。我想从那里我可以开始改变事情,看看会发生什么。介绍到此为止。

当我输入时

    nginx -t

我明白了

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

当我输入时

    ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543

我明白了

    Using paster config: paste_local.ini
    Using ./bin/paster
    + export CELERY_ALWAYS_EAGER=true
    + ./bin/paster serve paste_local.ini --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543 --reload
    Starting subprocess with file monitor
    2017-05-22 08:39:22,377 INFO    [mediagoblin.app] GNU MediaGoblin 0.9.0 main server starting
    2017-05-22 08:39:22,647 INFO    [mediagoblin.app] Setting up plugins.
    2017-05-22 08:39:22,648 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.geolocation
    2017-05-22 08:39:22,648 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.basic_auth
    2017-05-22 08:39:22,648 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.processing_info
    2017-05-22 08:39:22,648 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.media_types.image
    2017-05-22 08:39:22,797 INFO    [mediagoblin.init.celery] Setting celery configuration from object "mediagoblin.init.celery.dummy_settings_module"
    Starting server in PID 990.

似乎没有为服务器提供服务。当我转到服务器 ip 时,我会得到默认的 nginx 页面。

我的/etc/nginx/nginx.conf文件如下

    user www-data;
    worker_processes 4;
    pid /run/nginx.pid;
    events {
            worker_connections 768;
            # multi_accept on;
    }
    http {
            ##
            # Basic Settings
            ##
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            types_hash_max_size 2048;
            # server_tokens off;
            # server_names_hash_bucket_size 64;
            # server_name_in_redirect off;
            include /etc/nginx/mime.types;
            default_type application/octet-stream;
            ##
            # SSL Settings
            ##
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
            ssl_prefer_server_ciphers on;
            ##
            # Logging Settings
            ##
            access_log /var/log/nginx/access.log;
            error_log /var/log/nginx/error.log;
            ##
            # Gzip Settings
            ##
            gzip on;
            gzip_disable "msie6";
            # gzip_vary on;
            # gzip_proxied any;
            # gzip_comp_level 6;
            # gzip_buffers 16 8k;
            # gzip_http_version 1.1;
            # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
            ##
            # Virtual Host Configs
            ##
            include /etc/nginx/conf.d/*.conf;
            include /etc/nginx/sites-enabled/*;
    }

我的/etc/nginx/sites-enabled/nginx.conf如下

    server {
     #################################################
     # Stock useful config options, but ignore them :)
     #################################################
     include /etc/nginx/mime.types;
     autoindex off;
     default_type  application/octet-stream;
     sendfile on;
     # Gzip
     gzip on;
     gzip_min_length 1024;
     gzip_buffers 4 32k;
     gzip_types text/plain application/x-javascript text/javascript text/xml text/css;
     #####################################
     # Mounting MediaGoblin stuff
     # This is the section you should read
     #####################################

     # Change this to update the upload size limit for your users
     client_max_body_size 8m;

     # prevent attacks (someone uploading a .txt file that the browser
     # interprets as an HTML file, etc.)
     add_header X-Content-Type-Options nosniff;

     server_name mediagoblin.example.org www.mediagoblin.example.org;
     access_log /var/log/nginx/mediagoblin.example.access.log;
     error_log /var/log/nginx/mediagoblin.example.error.log;

     # MediaGoblin's stock static files: CSS, JS, etc.
     location /mgoblin_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/mediagoblin/static/;
     }

     # Instance specific media:
     location /mgoblin_media/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/media/public/;
     }

     # Theme static files (usually symlinked in)
     location /theme_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/theme_static/;
     }

     # Plugin static files (usually symlinked in)
     location /plugin_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/plugin_static/;
     }

     # Mounting MediaGoblin itself via FastCGI.
     location / {
        fastcgi_pass 127.0.0.1:26543;
        include /etc/nginx/fastcgi_params;

        # our understanding vs nginx's handling of script_name vs
        # path_info don't match :)
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param SCRIPT_NAME "";
     }
    }

任何建议将不胜感激。


编辑 1

运行响应

    ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543

还在

    Using paster config: paste_local.ini
    Using ./bin/paster
    + export CELERY_ALWAYS_EAGER=true
    + ./bin/paster serve paste_local.ini --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543 --reload
    Starting subprocess with file monitor
    2017-05-22 12:06:37,345 INFO    [mediagoblin.app] GNU MediaGoblin 0.9.0 main server starting
    2017-05-22 12:06:37,583 INFO    [mediagoblin.app] Setting up plugins.
    2017-05-22 12:06:37,584 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.geolocation
    2017-05-22 12:06:37,584 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.basic_auth
    2017-05-22 12:06:37,584 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.plugins.processing_info
    2017-05-22 12:06:37,585 INFO    [mediagoblin.init.plugins] Importing plugin module: mediagoblin.media_types.image
    2017-05-22 12:06:37,714 INFO    [mediagoblin.init.celery] Setting celery configuration from object "mediagoblin.init.celery.dummy_settings_module"
    Starting server in PID 976.

当前媒体地精 nginx.conf:

     server {
     #################################################
     # Stock useful config options, but ignore them :)
     #################################################
     include /etc/nginx/mime.types;

     autoindex off;
     default_type  application/octet-stream;
     sendfile on;

     # Gzip
     gzip on;
     gzip_min_length 1024;
     gzip_buffers 4 32k;
     gzip_types text/plain application/x-javascript text/javascript text/xml text/css;

        listen       80;
        server_name  10.1.1.74;


     #####################################
     # Mounting MediaGoblin stuff
     # This is the section you should read
     #####################################

     # Change this to update the upload size limit for your users
     client_max_body_size 8m;

     # prevent attacks (someone uploading a .txt file that the browser
     # interprets as an HTML file, etc.)
     add_header X-Content-Type-Options nosniff;

     server_name mediagoblin.example.org www.mediagoblin.example.org;
     access_log /var/log/nginx/mediagoblin.example.access.log;
     error_log /var/log/nginx/mediagoblin.example.error.log;

     # MediaGoblin's stock static files: CSS, JS, etc.
     location /mgoblin_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/mediagoblin/static/;
     }

     # Instance specific media:
     location /mgoblin_media/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/media/public/;
     }

     # Theme static files (usually symlinked in)
     location /theme_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/theme_static/;
     }

     # Plugin static files (usually symlinked in)
     location /plugin_static/ {
        alias /srv/mediagoblin.example.org/mediagoblin/user_dev/plugin_static/;
     }

     # Mounting MediaGoblin itself via FastCGI.
     location / {
        fastcgi_pass 127.0.0.1:26543;
        include /etc/nginx/fastcgi_params;

        # our understanding vs nginx's handling of script_name vs
        # path_info don't match :)
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param SCRIPT_NAME "";
     }
    }

当前/etc/nginx/nginx.conf:


编辑 2 服务器的当前 nginx.conf 文件(两个默认值都有效)

 server {
 #################################################
 # Stock useful config options, but ignore them :)
 #################################################
 include /etc/nginx/mime.types;

 autoindex off;
 default_type  application/octet-stream;
 sendfile on;

 # Gzip
 gzip on;
 gzip_min_length 1024;
 gzip_buffers 4 32k;
 gzip_types text/plain application/x-javascript text/javascript text/xml text/css;

    listen       80;
    server_name  10.0.0.192;


 #####################################
 # Mounting MediaGoblin stuff
 # This is the section you should read
 #####################################

 # Change this to update the upload size limit for your users
 client_max_body_size 8m;

 # prevent attacks (someone uploading a .txt file that the browser
 # interprets as an HTML file, etc.)
 add_header X-Content-Type-Options nosniff;

 server_name mediagoblin.example.org www.mediagoblin.example.org;
 access_log /var/log/nginx/mediagoblin.example.access.log;
 error_log /var/log/nginx/mediagoblin.example.error.log;

 # MediaGoblin's stock static files: CSS, JS, etc.
 location /mgoblin_static/ {
    alias /srv/mediagoblin.example.org/mediagoblin/mediagoblin/static/;
 }

 # Instance specific media:
 location /mgoblin_media/ {
    alias /srv/mediagoblin.example.org/mediagoblin/user_dev/media/public/;
 }

 # Theme static files (usually symlinked in)
 location /theme_static/ {
    alias /srv/mediagoblin.example.org/mediagoblin/user_dev/theme_static/;
 }

 # Plugin static files (usually symlinked in)
 location /plugin_static/ {
    alias /srv/mediagoblin.example.org/mediagoblin/user_dev/plugin_static/;
 }

 # Mounting MediaGoblin itself via FastCGI.
 location / {
    fastcgi_pass 10.0.0.192:26543;
    include /etc/nginx/fastcgi_params;

    # our understanding vs nginx's handling of script_name vs
    # path_info don't match :)
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param SCRIPT_NAME "";
 }
}

当我按照指南的建议运行此命令时,我无法加载页面。

    ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543

但是,当我运行此命令时,它可以工作。

    ./lazyserver.sh --server-name=fcgi fcgi_host=10.0.0.192 fcgi_port=26543

我不确定指南补充的第一个是否暗示您正在本地访问它...这是有道理的,因为在说明中创建的 dns url 应该可以在不隐式创建 dns 的情况下工作进入任何地方......或者,如果我仍然做错了什么。

【问题讨论】:

  • 您的配置文件中有错误。您现在有两个 server_name 指令 如果您删除了默认文件,则无需编辑此文件。但是现在,您应该使用 nginx -t 测试您的 nginx 配置

标签: nginx debian debian-jessie


【解决方案1】:

您可能在/etc/nginx/sites-enabled/ 中有一个默认服务器。如果您使用mediagoblin.example.org 访问服务器,那么您的服务器配置将匹配。

您声明您使用服务器的 IP 地址,这意味着将使用默认服务器。

您有多种选择:

  1. 您可以将 IP 地址添加到 server_name 指令中,并假装这是您服务器的有效名称。
  2. 您可以设置 DNS 或主机,以便使用正确的名称。
  3. 您可以删除其他配置文件,以便此配置成为事实上的默认服务器。

请参阅this document 了解更多信息。

【讨论】:

  • 我是否会删除默认站点并修改 /etc/nginx/sites-enabled/nginx.conf 中的新配置文件...该文件指向一个配置文件,该文件位于mediagoblin 目录
  • 您能否准确地告诉我我需要更改哪些内容才能让网站使用 mediagoblin nginx 配置文件运行。
  • 您是否有一个名为/etc/nginx/sites-enabled/default 的文件,它可能是指向/etc/nginx/sites-available/default 的符号链接?该文件导致您看到的默认 nginx 页面。如果您删除了/etc/nginx/sites-enabled/default,那么您的配置文件/etc/nginx/sites-enabled/nginx.conf(这也是一个符号链接——但这并不重要)应该在重启nginx之后开始工作。
  • 您好。我 rm /etc/nginx/sites-enabled/default 和 /etc/nginx/sites-available/default。然后我编辑 /etc/nginx/sites-enabled/nginx.conf ,如编辑后的帖子所示,但是我仍然收到相同的错误。还有其他信息可以提供帮助吗?
  • 我再次编辑它。顺便说一句,感谢您的所有帮助。它基于编辑二启动并运行。但是,如果我在lazyserver 命令中更改IP 地址,我不完全确定它为什么会起作用。似乎整套指令都打算在本地进行测试,如果是这样的话,为什么我一开始不能让它工作就说得通了。我在没有 gui 的情况下运行,所以测试来自另一个 vm。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多