• The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

How to connect nginx to work with a directory "web_users"?

Evgeny_Maltsev

New Pleskian
Hi.
How to connect nginx to work with directory web_users for some virtual host?
This directory contains two accounts (user1, user2) with a large amount of static content (files .jpg), the downloaded web users themselves. At the moment they are processed by Apache, which causes an additional load on the server.
In hosting configuration for virtual host "domain.tld" set:
document root: httpdocs. (That is, the "httpdocs" and "web_users" directories are on the same level).
In the web server configuration settings (in additional nginx directives) i can't use the directive "server" (refuses to save), where you can specify the location of the additional "document root" for nginx.
Help, please.
 
Have you tried add needed custom directives to the following file /var/www/vhosts/system/<domain_name>/conf/vhost_nginx.conf manually?
Do not forget to reconfigure vhosts after that with

# /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain <domain_name>
 
I tried in web server configuration settings (in additional nginx directives), all with negative result:
1. vhost_nginx.conf:
location ~ ^/\~user1/pub/(.+\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
alias /var/www/vhosts/domain.tld/web_users/user1/$1;
}
# /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.tld
2. vhost_nginx.conf:
location ~ ^/~user1/pub/(.+\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
alias /var/www/vhosts/domain.tld/web_users/user1/$1;
}
# /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.tld

This "locations" added in vhost_nginx.conf, but include of /var/www/vhosts/system/domain.tld/conf/vhost_nginx.conf in file nginx_ip_default.conf in section "server" follows the directive
location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
try_files $uri @fallback;
}

Here is section "server" from nginx_ip_default.conf (relevant to the issue directives):

server {
listen 1.1.1.1:80 default_server;

server_name domain.tld;
server_name www.domain.tld;
root "/var/www/vhosts/domain.tld/httpdocs";

if ($host ~* ^domain.tld$) {
rewrite ^(.*)$ http://www.domain.tld$1 permanent;
}

location / {
proxy_pass http://1.1.1.1:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}

location @fallback {
proxy_pass http://1.1.1.1:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}

location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
try_files $uri @fallback;
}

include "/var/www/vhosts/system/domain.tld/conf/vhost_nginx.conf";
}

What is my mistake?
 
I try more without result:
1. vhost_nginx.conf:
location /~user1/pub/ {
alias /var/www/vhosts/domain.tld/web_users/user1/;
}
2. vhost_nginx.conf:
location /\~user1/pub/ {
alias /var/www/vhosts/domain.tld/web_users/user1/;

Any ideas?
 
Back
Top