2

我已经在 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;
}
4

1 回答 1

1

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

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

有关上游的更多信息,可以查看这篇文章UpStream - Nginx

于 2020-01-19T15:36:28.760 回答