server { listen 81; server_name example.com localhost direct1.example.com www.example.com admin.example.com forum.example.com; location /media/ { root /var/www/vhosts/example.com/html; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location / { proxy_set_header Host $host; proxy_set_header Connection Close; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root /var/www/vhosts/example.com/html; proxy_pass http://127.0.0.1:80; } } This is what I have in nginx/defaults.conf. The server is currently using Apache fine, and Plesk, which seems to manage vhosts on its own (somehow).
Any requests to example.com:81/media/image.jpg work fine, but example.com:81 uses an incorrect vhost.
I'm not 100% sure how the vhost situation works with Plesk, but it was installed and the default vhost is server1.example.com, and no matter how much fiddling with the proxy settings I do, I can't get it to use the example.com vhost.
edit added a ; to the root line under location. It was missing, I tried adding it but still no luck.
update added ServerName "example.com" to /etc/httpd/conf.d/zz010_psa_httpd.conf. Now under apache-status, it lists the vhost as example.com, but still "uses" server1.example.com. Boo.
It also seems that it's using DocumentRoot from the main apache httpd.conf, and not using the proper virtual host.