【问题标题】:Configuring adminer with NGINX: "no port in upstream php" error使用 NGINX 配置管理员:“上游 php 中没有端口”错误
【发布时间】:2019-09-03 03:53:39
【问题描述】:

我已经在 Digital Ocean 中设置了带有 MongoDB 后端的 MeteorJs 应用程序。我现在正在尝试设置管理员,这样我就可以在不打开我的 Droplet 上的输入端口的情况下查询 MongoDB。每次我尝试重新加载 nginx 设置时,都会收到 nginx: [emerg] no port in upstream "php" in /etc/nginx/sites-enabled/admin:32 错误。 我错过了什么?

/etc/nginx/sites-enabled/admin

server {
    listen         80;
    server_name    165.227.197.220;
    return         301 https://$server_name$request_uri;
}

server {
    server_name    165.227.197.220;
    listen             443 ssl;
    access_log     /var/log/nginx/admin.access.log;
    error_log      /var/log/nginx/admin.error.log;

    ssl_certificate /etc/nginx/ssl/admin.crt;
    ssl_certificate_key /etc/nginx/ssl/admin.key;

    root           /var/www/admin;
    index          adminer.php;

    # Get file here https://codex.wordpress.org/Nginx
    include        global/restrictions.conf;

    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd/admin;

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php;
        fastcgi_index adminer.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

/etc/nginx/global/restrictions.conf

# Global restrictions configuration file.
# Designed to be included in any server {} block.
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
    deny all;
}

# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}

【问题讨论】:

    标签: php nginx digital-ocean adminer


    【解决方案1】:

    您需要设置一个上游,例如使用我们拥有的 wordpress

    upstream index_php_upstream {
        server 127.0.0.1:8090; # NGINX Unit backend address for index.php with
                               # 'script' parameter
    }
    

    更多关于upstream,可以查看这篇文章UpStream - Nginx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-07
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多