I have nginx config
its part
location ~ ^/api/(?<module>.+)/doc/ {
autoindex on;
index index.html;
alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1;
error_log /var/log/nginx/hub-test-error.log debug;
}
But when i make request, i have error
2015/03/06 18:46:43 [error] 11158#0: *1 opendir()
"/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/dashboar" failed
(2: No such file or directory), client: 127.0.0.1, server: hub.dev,
request: "GET /api/dashboard/doc/ HTTP/1.1", host: "hub.dev"
OR
2015/03/06 18:29:37 [error] 9941#0: *1 opendir() "/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/consultan" failed (2: No such file or directory), client: 127.0.0.1, server: hub.dev, request: "GET /api/consultant/doc/ HTTP/1.1", host: "hub.dev"
I try change config
location ~ ^/api/(consultant|dashboard)/doc/ {
but error the same.
nginx version: nginx/1.7.10
ubuntu 14.04 x64
Why i have this error? How fix it?
Do you know any oter way to configure nginx location for process different modules?
There was error in nginx version 1.7.10
In the latest versions thi error fixed.
So just update nginx.
I had the same problem, solved it by appending a slash to the path in the alias directive.
alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1/;
instead of
alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1;
I'd stab a guess that some code tries to remove a trailing slash but did end up eating every last character.
Related
Stuck even after having gone through all nginx + WordPress permalinks issue raised here.
I have WordPress installed in a subdirectory digitext-v1. Root directory only has phpinfo file.
root --> /var/www
subdirectory --> /var/www/digitext-v1
Plain permalinks work fine with home and all pages. Pretty permalinks work with home page but gives 404 error for all others.
My conf file is given below. Has almost identical setup (except for fqdn used in server name) to my live Nginx server where pretty permalinks work perfectly fine.
Can you help me resolve it before I lose my sanity? Anything to do with domain name? What am I doing wrong??
server {
listen 80;
server_name digitextv1 192.168.11.8;
root /var/www/digitext-v1;
index index.php index.html index.htm;
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location / {
# Setting pretty permalinks in WordPress
# First attempt to serve request as file ($uri)
# or directory ($uri/).
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
EDIT (few lines from error log)
2021/08/31 16:05:48 [error] 3185#3185: *1406 FastCGI sent in stderr: "PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106" while reading upstream, client: 192.168.11.41, server: 192.168.11.8, request: "GET /digitext-v1/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.11.8", referrer: "http://192.168.11.8/digitext-v1/wp-admin/options-permalink.php"
2021/08/31 16:06:28 [error] 3185#3185: *1426 FastCGI sent in stderr: "PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106" while reading upstream, client: 192.168.11.41, server: 192.168.11.8, request: "GET /digitext-v1/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.11.8"
2021/08/31 16:06:28 [error] 3185#3185: *1426 FastCGI sent in stderr: "PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106" while reading upstream, client: 192.168.11.41, server: 192.168.11.8, request: "GET /digitext-v1/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.11.8"
2021/08/31 16:09:59 [error] 3185#3185: *1438 FastCGI sent in stderr: "PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106" while reading upstream, client: 192.168.11.41, server: 192.168.11.8, request: "GET /digitext-v1/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.11.8", referrer: "http://192.168.11.8/digitext-v1/wp-admin/options-permalink.php"
2021/08/31 16:09:59 [error] 3185#3185: *1438 FastCGI sent in stderr: "PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106PHP message: PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/digitext-v1/wp-content/plugins/popup-maker/includes/functions/popups/template.php on line 106" while reading upstream, client: 192.168.11.41, server: 192.168.11.8, request: "GET /digitext-v1/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.11.8", referrer: "http://192.168.11.8/digitext-v1/wp-admin/options-permalink.php"
I had exactly the same issue this week. I even went so far as to reset WordPress, without success. I uploaded my .htacess file to my host advisor Chris at easy.dns and after some back and forth he deleted the following code to solve the problem:
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
<Files *config.json*>
order allow,deny
deny from all
</Files>
what is happening:
Im using following nginx.conf file for load balancing. web application is up and running on nginx 8080 port and able to access the landing page. however, when moving from landing page to "signup" page, it is throwing error.
what is expected:
nginx load balancer should redirect the load to the page as mentioned in the Location directive. but that is not happening.
nginx file :
events {
}
http {
upstream 3.121.253.126 {
server 3.121.253.126:8080;
server 3.121.253.126:8080;
server 3.121.253.126:8080;
}
error_log /etc/nginx/error_log.log warn;
client_max_body_size 20m;
proxy_cache_path /etc/nginx/cache keys_zone=one:500m max_size=1000m;
server {
listen 8080;
server_name 3.121.253.126;
root /etc/nginx/html;
index index.html;
location /signup {
root /etc/nginx/html;
index add-user.html;
# proxy_pass http://localhost:8080/signup;
# proxy_set_header Host $host;
# rewrite ^/welcome(.*)$ $1 break;
}
}
}
here is the error log:
2019/02/21 09:07:42 [error] 6#6: *510 recv() failed (104: Connection
reset by peer) while reading response header from upstream, client:
127.0.0.1, server: 3.121.253.126, request: "GET /signup HTTP/1.0", upstream: "http://127.0.0.1:8080/signup", host: "localhost:8080",
referrer: "http://3.121.253.126:8080/" 2019/02/21 09:07:42 [warn] 6#6:
*510 upstream server temporarily disabled while reading response header from upstream, client: 127.0.0.1, server: 3.121.253.126,
request: "GET /signup HTTP/1.0", upstream:
"http://127.0.0.1:8080/signup", host: "localhost:8080", referrer:
"http://3.121.253.126:8080/" 2019/02/21 09:13:10 [error] 6#6: *1
open() "/etc/nginx/html/signup" failed (2: No such file or directory),
client: 157.33.175.127, server: 3.121.253.126, request: "GET /signup
HTTP/1.1", host: "3.121.253.126:8080", referrer:
"http://3.121.253.126:8080/" 2019/02/21 09:15:57 [error] 6#6: *3
open() "/etc/nginx/html/signup" failed (2: No such file or directory),
client: 157.33.175.127, server: 3.121.253.126, request: "GET /signup
HTTP/1.1", host: "3.121.253.126:8080", referrer:
"http://3.121.253.126:8080/"
as per log, it is expecting signup html file. however, i am instructing it to use the add-user.html file. not sure why this is not happening.
please suggest
You want to point the URI /signup to the file located at /etc/nginx/html/add-user.html
There are a number of ways to achieve that using Nginx, including the rewrite and try_files directives.
For example:
location /signup {
try_files /add-user.html =404;
}
The root directive does not need to be repeated within this location block, as it will inherit the same value from the surrounding block.
The =404 does nothing as add-user.html always exists, but try_files requires two parameters. See this document for details.
The above location will process any request that begins with /signup (e.g. /signup/ or /signups).
To restrict it to the single URI /signup use the = modifier. See this document for details.
For example:
location = /signup {
try_files /add-user.html =404;
}
I would like to match a specific location URL to serve a static file on my website
Here is the two behaviors that I would like to implement :
(WORKING but an error appears on the logs)
http://mywebsite.net serves /var/www/html/portfolio/index.html
(NOT WORKING) http://mywebsite.net/project serves /var/www/html/project/build/index.html
Here is my actual code :
server {
listen 80 default_server;
listen [::]:80 default_server;
error_log /home/florian/nginx_www.error.log;
root /var/www/html/portfolio;
index index.html;
location = /project {
root /var/www/html/project/build;
index index.html;
}
}
Here is the actual error I get :
2019/01/19 20:38:47 [error] 7780#7780: *4 open()
"/var/www/html/project/build/project" failed (2: No such file or
directory), client: XX.XX.XX.XX, server: , request: "GET /project
HTTP/1.1", host: "mywebsite.xx.net"
This behavior is actually normal because this URL doesn't give anything correct.
I would like that the URL served:
/var/www/html/project/build/project
becomes
/var/www/html/project/build/
Additionnaly, I also have an issue when I reach the my website using this URL http://mywebsite.net . However the files are still being served
2019/01/19 20:37:46 [error] 7780#7780: *5 open()
"/var/www/html/portfolio/undefined" failed (2: No such file or
directory), client: XX.XX.XX.XX, server: , request: "GET /undefined
HTTP/1.1", host: "mywebsite.xx.net", referrer:
"http://mywebsite.xx.net/"
I am trying to configure nginx to serve up error pages from an s3 bucket.
To that end my configuration looks like this:
location / {
error_page 404 = #fallback;
}
location #fallback {
rewrite ^ /my-s3-bucket/404.html;
proxy_pass https://s3.ap-northeast-2.amazonaws.com;
}
My expectation is that anything that hits the website and is not found is then sent to the #fallback location. I then want to rewrite the URL with the actual location of my 404 page and send on to the s3 bucket. I don't want to just 302 redirect to the 404 page.
The problem is that the proxy_pass directive is not executed. Instead, it just looks for my rewritten URL locally.
See my access logs below:
2019/01/07 03:05:42 [error] 85#85: *3 open() "/etc/nginx/html/sdfd" failed (2: No such file or directory), client: 172.17.0.1, server: www.dev.mywebsite.com.au, request: "GET /sdfd HTTP/2.0", host: "www.dev.mywebsite.com.au"
2019/01/07 03:05:42 [error] 85#85: *3 open() "/etc/nginx/html/my-s3-bucket/404.html" failed (2: No such file or directory), client: 172.17.0.1, server: www.dev.mywebsite.com.au, request: "GET /sdfd HTTP/2.0", host: "www.dev.mywebsite.com.au"
I made a request to www.dev.mywebsite.com.au/sdfd which wasn't found. 'sdfs' was rewritten to 'my-s3-bucket/404.html' but instead of then proxy passing that to https://s3.ap-northeast-2.amazonaws.com it looks for it in the local /etc/nginx/html directory.
My nginx version is 1.15.2
Use rewrite...break if you want the rewritten URI to be processed within the same location block. See this document for more.
For example:
location #fallback {
rewrite ^ /error/404.html break;
proxy_pass https://example.com;
}
Right now I've got Nginx setup to serve what I'm pretty sure is a valid filepath. However, it's giving me a 404 not found.
I've looked in /var/log/nginx/access.log and it shows me:
[05/Oct/2016:19:15:50 -0500] "GET /menu.html HTTP/1.1" 404 571 "-" "Mozilla/5.0 ....
But not what path it was trying to access on localhost, which should be /usr/share/nginx/html/menu.html. How do I configure Nginx to show me this information?
I recommend to try log_format directive with $realpath_root (or $document_root) and $request_filename attribute.
Read this documentations and customize Your logs as You wish:
http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps
I believe the full path is shown in the error_log file for a 404.
Example:
2017/02/10 12:20:45 [error] : *239 open() "/usr/local/files/myFile.js" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: myserver.com, request: "GET /path/to/myFile.js HTTP/1.1", host: "myserver.com", referrer: "http://myserver.com/home"