I'm trying to set up a reverse proxy server using nginx 1.20.1 on Fedora Server 35, but everything I've tried so far results in an error:
[root@proxy nginx]# curl -I -H "Host: www.example.com" http://10.0.19.1/
HTTP/1.1 500 Internal Server Error
Server: nginx/1.20.1
Date: Wed, 10 Nov 2021 19:54:39 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/8.0.12
10.0.19.1 is the address of the nginx server, and 10.0.20.1 is an Apache server which I'm trying to proxy. If I run the same curl command as above, but using 10.0.20.1 for the URL, it works fine, so I think it's safe to rule out connectivity issues between the two servers, and any problem with the Apache host. The nginx error log is empty.
nginx -t
Finds no problems with the config files (reproduced below). I also set SELinux to permissive for now to eliminate that as a cause.
I did create a simple (non-proxy) server configuration to test, and that worked OK, so being new to nginx, I get the feeling this is a probably a very trivial problem with my proxy.conf file.
nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
conf.d/proxy.conf:
server {
listen 80;
server_name www.example.com;
location / {
proxy_pass http://10.0.20.1;
}
}