Quantcast
Channel: Nginx Forum - How to...
Viewing all 2931 articles
Browse latest View live

Confused with the Equal modifier... (no replies)

$
0
0
This is how my configuration looks like...

server {
listen 80;
server_name 127.0.0.1 localhost;

location = / {
index index.html;
}

location / {
root /etc/nginx/html/app1;
}
}


In my folder app1 I have two files, index.html & home.html

If I browse http://localhost/ or http://localhost/index.html or http://localhost/home.html page it comes up well.

When I change the configuration like so...

server {
listen 80;
server_name 127.0.0.1 localhost;

location = / {
index home.html;
}

location / {
root /etc/nginx/html/app1;
}
}

http://localhost:8888/index.html > works
http://localhost:8888/home.html > works
http://localhost:8888/ > 403 forbidden!!!

Can someone please tell me what is wrong?

Proxy pass protocol version HTTP/2 (no replies)

$
0
0
Hello!

I use nginx-1.9.5 with ngx_http_v2_module.
I want to pass HTTP/1.x traffic to one backend and HTTP/2 traffic to another. I don't want to convert HTTP/2 trafic to HTTP/1.x.
Is it possible?

As I know the proxy_http_version directive allows only 1.0 and 1.1.

My config:

http {
    # HTTP/2 vs HTTP/1.x proxy port
    map $http2 $site_ru_proxy_port {
        default  9000; # pass to HTTP/1.x backend
        "h2"      9001; # pass to HTTP/2 bakend
    }
    
    # HTTP/1.x + HTTP/2 over TLS
    server {
        listen               443 ssl http2;
        server_name  site.ru;
    
        # SSL STUFF
    
        location / {
            proxy_pass     http://127.0.0.1:$site_ru_proxy_port;
        }
    }
}

systemd nginx.service start request NOT so quickly! (no replies)

$
0
0
Hello everybody I'm a new forum user and a new Nginx enthusiastic user!

I need some help....

Sometimes, once a week nginx stops ...

into systemd.log I found this line...... systemd: nginx.service start request repeated too quickly, refusing to start.

some idea to delay the restart ?

Case Sensitivity issue in Nginx (no replies)

$
0
0
This is my directory structure...

html
|-- 50x.html
|-- app1
| `-- index.html
|-- app2
| |-- home.html
| `-- index.html
|-- common
| |-- app.js
| `-- index.html
`-- index.html


And this is the configuration...

server {
listen 80;
server_name 127.0.0.1 localhost;
root /etc/nginx/html;

location /app1/ {
index index.html;
}

location ~* /app2/ {
index home.html;
}
}

http://localhost/app2 > Works
http://localhost/App2 > Doesn't work

What am I doing wrong?

Nginx (WPN-XM) and multiple Magento installations (1 reply)

$
0
0
How do I configure nginx to work with multiple Magento installations? I think nginx needs to be configured to dynamically change root directory, but I'm unsure how to do this or if it is even possible.

Root is now C:\server\www

I have multiple Magento installations:
C:\server\www\magento1
C:\server\www\anothermagento
C:\server\www\testmagento

Magento frontpages work fine if for example I try to access addresses:
http://localhost/magento1
http://localhost/anothermagento
http://localhost/testmagento

But if I try to access admin login page, I get Error 404:
http://localhost/magento1/admin
http://localhost/anothermagento/admin
http://localhost/testmagento/admin

Nothing works that comes after http://localhost/SOMESITEHERE/...

I know I could do something like this for each magento installation:

location @magento_handler
{
rewrite /magento1/ /magento1/index.php;
}

location /magento1/
{
index index.html index.php;
try_files $uri $uri/ @magento_handler;
}

But I would really like it if I didn't have to add own configuration for every site...

NGINX PHP Subfolder Problem & Downloading File (no replies)

$
0
0
I had PHP on NGINX Setup and working to where I got the NGINX welcome screen as index.html and info.php showing properly. However, I created a folder with permissions 777 and put another php file in there. Upon trying to exceute that php file I get 404! Also I had a non-php file in the main folder for users to download. However, trying to download that file instead redirects to index.html. Please help. Here is the config for /etc/nginx/sites-available/default

server { listen 80; listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# 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)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

nginx listen on IPIP-interface (tun0) (1 reply)

$
0
0
Hi,

currently trying to configure nginx behind a keepalived loadbalancer with lb_kind TUN.
The idea behind this setup is, to realize a location based load balancing on layer 4.
Higher layer should processed within final location with ngninx.

Part of this setup is, that nginx must listen on a tun0 IPIP-interface.

config snippet:

server {
listen 10.40.100.150:80;
location / {
proxy_pass http://cdms-g60-02:14002;
}
}


local ip addr output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:a1:71:11 brd ff:ff:ff:ff:ff:ff
inet 10.60.0.29/22 brd 10.60.3.255 scope global ens160
valid_lft forever preferred_lft forever
3: tunl0: <NOARP> mtu 0 qdisc noop state DOWN
link/ipip 0.0.0.0 brd 0.0.0.0
4: tun0@NONE: <NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN
link/ipip 10.60.0.29 brd 0.0.0.0
inet 10.40.100.150/32 scope global tun0
valid_lft forever preferred_lft forever

nginx starts without any error message.

# netstat -an | grep 10.40.100.150:80
tcp 0 0 10.40.100.150:80 0.0.0.0:* LISTEN

packets arriving throught tunnel interface: works fine (checked with tcpdump)

but nothing will return to sender.
currently I can't find any request within nginx access_log
no error messages are reported during a http request ...

it looks like that nginx currently not receive any http request

same setup works find with some other java applications (graylog2, elasticsearch) and named, ntp, smtp, ...
currently I'm a little bit perplexed and I have no idea how to fix this problem.

idea's ?
is this a bug or a feature ?



any help is welcome !

Steffen

Nginx with MySQL doesnt log fail to authtenticate in logs (1 reply)

$
0
0
Hi,

I have Nginx configured and running as I wanted.
Next step is to implement some log monitoring my my server (Fail2Ban) to block what needs to be blocked.
In doing so what I have found is that when someone try to log in with wrong username and/or password nothing out of the ordinary gets logged into the access.log.
The exact same line in the log appears when you display the login page. Then nothing gets logged about user name and password being wrong and finally (as the page refreshes) to display the invalid credentials warning, the oringal log entry happens again. An example:

117.100.101.199 - - [22/Oct/2015:23:16:13 +0800] "POST /xxx/api/tokens HTTP/1.1" 403 156 "https://fake.url.com/xxx/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"

If I am going to use Fail2Ban with the above line it will ban all requests (good and bad).

In the error log there isn't much to display either.

How can I Nginx to add more "meat" to the logs (such failed authentication message and others).

Thanks again guys.

nginx keeps redirecting to welcome page (1 reply)

$
0
0
I am using the following config:

server {
listen 80;
server_name 192.168.1.10;
location /shutter {
proxy_pass http://192.168.1.10:8989;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

The application I am using is called shutter lite: http://www.den4b.com/?x=products&product=shutter

When I enter

http://192.168.1.10:8989

it takes me to 'login' screen and then the web interface of the application, so that works.

But, When I enter

http://192.168.1.10/shutter

I get to the 'login' screen for the application. As soon as I login, it takes me to the nginx welcome screen instead of the web interface of the application.

The above config works for other applications, it is only the shutter application that gives me this problem.

I am not sure where I am going wrong..

Any suggestions?

NGINX as revproxy cached failover solution (no replies)

$
0
0
Hi,

I'm trying to setup NGINX as a reverse proxy, cached fail over solution - similar to Newrelic's 'Always Online' feature. So far, I have it working, but now how I'd like.

What I'd like is for the cached pages to display the live web pages, and only present a cached page upon error. Is this possible? If so, I can just have DNS point to the rev proxy server.

Here is a host config.

GNU nano 2.3.6 File: origin.domain.com

server {
listen 80;
server_name origin.domain.com;
location / {
proxy_pass http://10.1.4.171/;
proxy_set_header Host $host;
proxy_cache STATIC;
proxy_cache_valid 200 2m;
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;
proxy_cache_use_stale error timeout invalid_header updating http_403 http_500 http_502 http_503 http_504;
}
}

This is a multi host setup. Here is nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=STATIC:100m inactive=24h max_size=5g;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

# Virtual Host Configs
include /etc/nginx/sites-enabled/*;
include /etc/nginx/conf.d/*.conf;

}

Speed up perl by loading modules into memory? (no replies)

$
0
0
Hi,

I'm trying to get my perl scripts speeds up with nginx. We include quite a few perl modules - so I'm wondering if we can load them into memory, to speed up script requests. Here is a post I've started on Stack Overflow:

http://stackoverflow.com/questions/33316610/loading-perl-modules-into-memory-for-nginx-to-make-faster/33343357#33343357

Now, while I don't get errors on rebooting nginx, I really don't see that much of a difference in load times.

Before: 896ms "waiting"
After: 845ms "waiting"

Am I mis understanding how the perl_require works? Basically, I want to emulate what you get with mod_perl on Apache (where it loads the modules into memory)

Thanks

Andy

FastCGI Cache /purge/ resulting in 404 and no catch purging (1 reply)

$
0
0
I'm encountering an issue with my server being unable to purge content using the nginx helper plugin. I'm using the code below, which shou;ld purge correctly using the nginx purge module, but whenever /purge/ is called it results in a 404.

I'm using:
Nginx 1.9.5
HHVM (latest)
WordPress

I've verified the cache's hit, miss, bypass, expired status in the header and in the directory itself. Caching works without issue. The problem happens when I try to purge. So what nginx helper does is conditional purging when you make a post. It does this by adding /purge/ to the address. So purging mydomain.com/test-post would be mydomain.com/purge/test-post. When I do an action to trigger the conditional purging, it fails to remove the contents of /var/run/nginx-cache. In additional, manually surfing to mydomain.com/purge/test-post results in an nginx 404 error, which is different than what would happen if I visited a regular non-existent page on the site. So if I visited mydomain.com/this-page-doesnt-exist, WordPress would handle the error internally and tell me "Oops! That page can’t be found". So clearly the /purge rewrite is doing something, but it's just resulting in 404 every time. Why it's doing this is a total mystery to me.

Here are the relevant contents of my .conf files, with the non-important stuff removed.
#inside nginx.conf
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=FCGICACHE:500m inactive=60m;
fastcgi_cache_key $scheme$request_method$host$request_uri;
fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 90;
fastcgi_read_timeout 90;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_max_temp_file_size 5m;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;



Below is located inside my hvvm.conf file, which is called from mydomain.com.conf.

# inside hhvm.conf
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache FCGICACHE;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 1h;
fastcgi_cache_min_uses 2;
add_header X-FastCGI-Cached $upstream_cache_status;

location ~ /purge(/.*) {
fastcgi_cache_purge FCGICACHE $scheme$request_method$host$request_uri;
}

How to redirect port on static ip> (no replies)

$
0
0
Hello. Im kind of noob here so sorry if my question seems dumb to you.
I am hosting a gps server traccar using a linux server. It works like charm. The only problem im facing right now is that the chinesse gps devices i bought on a lot sale do not accept an address for the server direction, only ip. Im familiar with dyndns in which for example a cctv dvr updates the current public dynamic ip into the server so the user can access anytime doesnt matter the ip changes.
Ive been trying to find the same concept but with a static ip instead of a text url. I know it might not work that way but i hope you can help me out.
Ive been doing some research and there are some satic ip vpns out there but they seem to allow only 1 connection. assuming i have 5 or 50 gps. they will transmit each 2 minutes, a lot of them will probably fail to conect. the data transfer is very low, for example a gps uses 5-10 mb per month, but they have to connect constantly to report the location.

I asked a sales rep from bestproxyandvpn.com and this is his reply
Hello,
I'm afraid that VPN will only allow one connection at a time on that particular VPN account and it will not work on your particular use case.
What you need is a VPS with dedicated IP and a reverse proxy like nginx or haproxy installed that would redirect incoming connections to your server. Your server will also need to update it's current IP to haproxy/nginx each minute.
Neither proxies nor VPN will work for this.
Thank you for your interest!
Best regards,
Adrian

So, here I am, I just dont understand how nginx works. because its open source, no montly payment. but will i get a static ip? i dont mind if its a shared ip as long as i have a dedicated port that forwards the incomming connection to my dynamic ip. The problem with the vpns is that i dont want all my outgoing connetions to be triangled to another location. I only want as i said, a satic ip with a specific or non-specific port, and then the connetion is redirected to a dynamic ip.

Im not familiar with advanced terminologies, but i hope you can help me out.
Thank you in advance

nginx-1.8.0 on centos5.4 not work (no replies)

$
0
0
hi there,

When I start nginx-1.8.0 on centos 5.4, it cant found work processes, it's very puzzled. But when I compile the source code, it doesnt report any error.

Does nginx-1.8.0 is not compatible with centos 5.4?

Please give me a help, thanks.

How to limit HTTP/2 connections per IP? (no replies)

$
0
0
From the documentation of ngx_http_limit_conn_module:

>In HTTP/2 and SPDY, each concurrent request is considered a separate connection.

So is there a way limit HTTP/2 connections, not requests?

Also, doesn't this mean an attacker can establish any number of concurrent connections?

Nginx cache noob question (no replies)

$
0
0
While going through the documentation here https://www.nginx.com/blog/inside-nginx-how-we-designed-for-performance-scale/ I found that Nginx loads "cache helper processes" if caching is enabled.

Does this happen only in Nginx Plus, or also happens when one uses simple directives like expire, etc. I tried using expire but I can't see the loaders...


root 29673 13588 0 20:14 pts/1 00:00:00 \_ grep --color=auto nginx
root 19607 1 0 16:24 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 29636 19607 0 20:09 ? 00:00:00 \_ nginx: worker process
nginx 29637 19607 0 20:09 ? 00:00:00 \_ nginx: worker process
nginx 29638 19607 0 20:09 ? 00:00:00 \_ nginx: worker process
nginx 29639 19607 0 20:09 ? 00:00:00 \_ nginx: worker process

How to change host (no replies)

$
0
0
Hi everyone, first of all I'm not engineer, technician, programmer...

I have installed nginx from source on my laptop, this is my .conf file :

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

###################################

I have a simply (and trivial) question:
How to change "localhost" address to (for example) "homelaptop" ?

NB: I don't wont put my pc on internet, but in my home network

nginx run on centos 7.1 (no replies)

$
0
0
Does anybody run nginx on centos 7.1?

%cpu is much higher than on other systems?

I run nginx-1.8.0 and nginx-1.2.7 on centos7.1, I find %cpu nginx-1.2.7 on centos 5.4 is much higher on centos7.1.

Does anybody meet the problem?

Any advice.

Thanks.

Same URL fails when there are query parameters (no replies)

$
0
0
When I browse to www.mywebsite.com/lib/auth/index.php the page displays the way I want it.
However, once I introduce query or url parameters (www.mywebsite.com/lib/auth/index.php?state=somevalue&do=something), the same url gives me a 502 bad gateway error. Attached is my nginx site config

Server redirect without rewrite rules in Nginx config (2 replies)

$
0
0
Hello,
we are planning to use Nginx for static websites hosting generated by Jekyll. Sites are generated and deployed directly from GIT by "not trusted" users. "Not trusted" means they are trusted enough to publish something on their websites, but not enough to allow them change Nginx config of shared webserver.

Nginx has all pros, but only one negative point: Server redirects specified in "not trusted" file in website directory (like .htaccess from Apache).

Part of the discussion has happened yet in jekyll-redirect-from issue: https://github.com/jekyll/jekyll-redirect-from/issues/49 But there is missing the voice of someone who knows well Nginx.

Jekyll-redirect-from is plugin what generates HTML files in place of origin path with <meta http-equiv=refresh content="0; url=/new/path">. This plugin is well adopted in Jekyll community, so preffered solution is to use it (inc. extend it by some feature).

Is there some possibility to configure Nginx to send 301 redirect if he find file with meta refresh?

This will be propably very slow, so is there way to cache it?

Or to add feature to jekyll-redirect-from to generate something what Nginx can parse without everhead on not-redirected paths? (like discussed in the issue)
Viewing all 2931 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>