我是 nginx 的新手。
我有一个 php 服务器在 127.0.0.1:82 上监听(从 adminer firectory 开始,所以它在请求时提供 adminer.php)和 127.0.0.1:80 上的 nginx。我需要将任何 /admin 请求重定向到 Adminer,即 PHP 服务器。当我尝试 localhost:82/aminer.php 时,它工作得很好。但是当我通过 nginx (localhost:80/admin/aminer.php) 尝试它时,只有起始页有效。当我尝试授权时,我得到的 HTTP 响应有代码 403(访问被拒绝)。如果我输入了错误的密码,GUI 不会显示“用户 'Admin' 登录失败”之类的错误,它只会重置页面。
我想不出问题。
这是我的 nginx 配置文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http
{
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server
{
listen localhost:80;
location /admin/
{
proxy_pass http://localhost:82/;
proxy_no_cache 1;
}
}
##
# 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 TLSv1.3; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;
##
# Logging Settings
##
##
# Gzip Settings
##
gzip on;
# 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
##
}