Why does not the nginx rewrite?
"[FAIL] Reloading nginx configuration: nginx failed!"
rewrite ^/([0-9]+)/test.php http://domain.com:$1/;test.php last;
Destination address:
http://domain.com:1234/;test.php
When you use this syntax you will always have error
nginx: [emerg] unknown directive "test.php"
nginx: configuration file /etc/nginx/nginx.conf test failed
all text after
http://domain.com:$1/;
this is new directive.
In your example test.php == directive, the same as server_tokens or keepalive_timeout.
So, if you want that your rewrite will be correct use this syntax
rewrite '^/([0-9]+)/test.php' 'http://domain.com:$1/;test.php' last;
Related
Today, I installed mod_security for nginx. I added the following block to
server {
listen 80;
server_name mydomain.com;
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
location / {
proxy_pass http://10.0.1.54:8002;
}
After restarting Nginx, I got the following error:
nginx: [emerg] "try_files" directive Rule id: 254 is duplicated
in /etc/nginx/nginx.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed
What is going wrong? how to fix it?
This guide installed is here: https://www.tecmint.com/install-modsecurity-nginx-debian-ubuntu/
i need to proxy pass one URL from my internal network, that looks like this here:
http://<user><passwd><ipaddress>:<port>/cgi-bin/mjpg/video.cgi?channel=1&subtype=1
But this configuration always ends up in an error:
nginx: [emerg] invalid port in upstream "user:passwd#192.168.133.122:8080/cgi-bin/mjpg/video.cgi?channel=1&subtype=1" in /etc/nginx/sites-enabled/default:15
nginx: configuration file /etc/nginx/nginx.conf test failed
The only working way i get nginx to work is this one:
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm;
location /video.cgi {
proxy_pass http://192.168.133.122:8080/cgi-bin/mjpg/video.cgi?channel=1&subtype=1;
}
}
But in this configuration the User and the Password are not included. Is there a way to get user&password also in the proxy_pass?
thanks
Franz
I'm a noob an nginx (and apache and php ...)
I've this flask app that works fine from:
http://127.0.0.1:5000
and also externally from
http://myhost.com:5000
I would like to use that from
myhost.com/rest_1
to make room to others rest, like myhost.com/rest_2 .. 3 and so on.
The app resides in
/opt/rest_1
and uses some resources from it's /static folder like css and jquery.
I've this
/etc/nginx/sites-available/rest_1.conf
server {
listen 80;
listen [::]:80;
server_name myhost.com;
server_name_in_redirect off;
location /rest_1 {
rewrite ^/rest_1(.*) /$1 break;
proxy_pass http://127.0.0.1:5000/;
}}
and it's link to sites-enabled.
nginx restart and reload with no errors.
Other configurations are default from installation.
When i try to connect to
myhost.com/rest_1
I can see an incomplete page partially working, looking at nginx log:
/var/log/nginx/error.log:
*8 open() "/usr/share/nginx/html/static/w3.css" failed (2: No such file or directory), client: xx.xx.xx.xx, server: myhost.com, request: "GET /static/w3.css HTTP/1.1", host: "myhost.com", referrer: "http://myhost.com/rest_1"
So, it is clear to me that '/usr/share/nginx/html/' is got from elsewhere... and should also have a proper name that piece of folder (I'm a noob!!)
How to tell to the engine to redirect to the correct path on
/opt/rest_1
to get back all /static functionalities ?
OS: ubuntu server 16.04
nginx: 1.10.3
Thanks.
Cause you donĀ“t set one location resource for your static content. Your app is referencing an CSS from de root folder and not from rest_1.
Your CSS Call was http://myhost.com/STATIC, so it not match in the location that you set and try inside the default.
So you can solve it in your app or you can set it in your nginx as below:
location /static {
root /opt/rest_1;
}
I'm having a problem with nginx configuration.
When I set the configuration like this:
server {
server_name redmine;
listen 80;
location / {
proxy_pass http://172.16.0.70:33000;
}
}
I get this error nginx: [emerg] unknown directive "proxy_pass".
My nginx version is nginx/1.8.0.
Someone know what i'm missing or what i'm doing wrong? Thanks.
Seems that module ngx_http_proxy_module is not installed
Run nginx -V to view how nginx is configured. If it is configured with option --without-http_proxy_module than nginx doesn't have proxy module and should be recompiled.
What am I doing wrong here?
http {
limit_conn_zone $binary_remote_addr zone=one:63m;
server {
location /downloads/ {
limit_conn one 10;}
[root#batman1 ~]# service nginx configtest
nginx: [emerg] the size 66060288 of shared memory zone "one" conflicts with already declared size 0 in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed
Thx!
I resolve my miss configuration.
Only changing of position my include to the final.
On nginx.conf I put the directive limit_conn_zone after the include.
and that cause the error.
Moving the include directive is all solve.