We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Adding Code To Nginx File
Adding Code To Nginx File
Hey guys my script required a code to be added to nginx files as i am running fcgid
Note : I have replaced mywebsite name with mywebsite.com
It said to add the code to the nginx.conf
but when i try to add it to
/home/hosting/conf/web/nginx.conf
and restart nginx it says
Still the same error
so please tell me what to do so that the code works in /home/hosting/conf/web/nginx.conf
Note : I have replaced mywebsite name with mywebsite.com
Code: Select all
location /files {
root /home/hosting/web/mywebsite.com/public_html;
post_action @afterdownload;
internal;
}
location @afterdownload {
proxy_pass http://hostingrill.co/plugins/rewards/site/_log_download.php?request_uri=$request_uri&remote_addr=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion&content_length=$content_length&http_user_agent=$http_user_agent&http_referer=$http_referer&args=$args;
internal;
}
but when i try to add it to
/home/hosting/conf/web/nginx.conf
and restart nginx it says
and also i tried adding it to /etc/nginx/conf.d/myip.conf (Myip is the my ipaddress even though the code shouldnt be added there )nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/158.69.5.207.conf:10
nginx: configuration file /etc/nginx/nginx.conf test failed
Still the same error
so please tell me what to do so that the code works in /home/hosting/conf/web/nginx.conf
Re: Adding Code To Nginx File
When you add code to /home/admin/conf/web/nginx.conf which error do you get?
Add your code right and try command
Show us error and full config text.
Add your code right and try command
Code: Select all
nginx -t
Show us error and full config text.
Re: Adding Code To Nginx File
The Error
Full file
Code: Select all
[root@picu ~]# nginx -t
nginx: [emerg] "location" directive is not allowed here in /home/hosting/conf/web/nginx.conf:33
nginx: configuration file /etc/nginx/nginx.conf test failed
Code: Select all
server {
listen 158.69.5.207:80;
server_name hostingrill.co www.hostingrill.co hostingrill-co.picu.pk;
error_log /var/log/httpd/domains/hostingrill.co.error.log error;
location / {
proxy_pass http://158.69.5.207:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/hosting/web/hostingrill.co/public_html;
access_log /var/log/httpd/domains/hostingrill.co.log combined;
access_log /var/log/httpd/domains/hostingrill.co.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/hosting/web/hostingrill.co/document_errors/;
}
location @fallback {
proxy_pass http://158.69.5.207:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/hosting/conf/web/nginx.hostingrill.co.conf*;
}
location /files {
root /home/hosting/web/mywebsite.com/public_html;
post_action @afterdownload;
internal;
}
location @afterdownload {
proxy_pass http://hostingrill.co/plugins/rewards/site/_log_download.php?request_uri=$request_uri&remote_addr=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion&content_length=$content_length&http_user_agent=$http_user_agent&http_referer=$http_referer&args=$args;
internal;
}
Re: Adding Code To Nginx File
You add your config part too low and get error, check this:
Code: Select all
server {
listen 158.69.5.207:80;
server_name hostingrill.co www.hostingrill.co hostingrill-co.picu.pk;
error_log /var/log/httpd/domains/hostingrill.co.error.log error;
location / {
proxy_pass http://158.69.5.207:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/hosting/web/hostingrill.co/public_html;
access_log /var/log/httpd/domains/hostingrill.co.log combined;
access_log /var/log/httpd/domains/hostingrill.co.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /files {
root /home/hosting/web/mywebsite.com/public_html;
post_action @afterdownload;
internal;
}
location @afterdownload {
proxy_pass http://hostingrill.co/plugins/rewards/site/_log_download.php?request_uri=$request_uri&remote_addr=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion&content_length=$content_length&http_user_agent=$http_user_agent&http_referer=$http_referer&args=$args;
internal;
}
location /error/ {
alias /home/hosting/web/hostingrill.co/document_errors/;
}
location @fallback {
proxy_pass http://158.69.5.207:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/hosting/conf/web/nginx.hostingrill.co.conf*;
}
Re: Adding Code To Nginx File
wow thanks mate works good :)
Re: Adding Code To Nginx File
You're welcome ;-)