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

Drupal Infrastructure load balancer latency issue (1 reply)

$
0
0
Fairly new to nginx person here, looking forward to learning more about it.

We have a somewhat unique situation here, been doing some googling and whatnot and haven't really found anyone experiencing the same issue in a similar environment.

We seem to be getting a strange 5-8 second pause when loading pages from our cluster. Nginx is currently just running as a load balancer, behind it we have two web servers running Apache and varnish (it's a Drupal environment). If you load a page direct from one of the Apache servers, the page loads immediately. The 5-8 pause only occurs when accessing pages via the nginx load balancer.

Would be glad to post any config files or more information that would help would troubleshooting. Appreciate any and all help!

nginx goes down after creation of subdomains (3 replies)

$
0
0
Hello,

I provide web hosting with cPanel + Linux CentOs + PHP + MySQL + nginx

But usually when one of the users wants to create a subdomain the nginx goes down taking down all the websites of the server.

If I login as root and do:

/etc/init.d/nginx start

Starting nginx daemon: nginx nginx: [emerg] no host in ":80" of the "listen" directive in /etc/nginx/vhosts/subdomain.domain.com:3

I want to avoid all the websites down as result of one error in just one account.

Ideas?

Thank you

Proxy redirect to another local IP (no replies)

$
0
0
Dear all,
I'm new to the world of nginx and not skilled at all.
I managed to make it run on my server (.0.200) with the current configuration:

server {
listen *:9999;
server_name 192.168.0.200
location / { root /var/www/; } # simple index.html
location /headphones { proxy_pass http://192.168.0.200:8181/headphones; }
} # a proxy redirect of a service running my server and it is working

I've struggled to configure another proxy redirect without success.

1st: on the same network I have a phone (http://192.168.0.100/login.html)
I've tried with
location /phone/ { proxy_pass http://192.168.0.100:80/; }
but when I browse http://192.168.0.200:9999/phone/ I'm redirected to http://192.168.0.100/login.html while I would expect http://192.168.0.200:9999/phone/login.html

Someone can suggest me how to proceed

thanks for your patience.
kind regards
stef

Block file access in specific directory (no replies)

$
0
0
I need to block access to log files that are stored in a publicly accessible directory from being viewed publicly. These are stored as CGI files and as things are right now, anyone can view the directory directly and download the .CGI file which is a huge security concern as it showcases IP address of visitors and other things.


How can I block access to "/path/to/the/directory/*.cgi" ?

I tried:

location /path/to/the/directory/*.cgi {
deny all;
}

But it did not work.

SYNTAX : ~^(?.+)\.MYSITE\.com$ (no replies)

$
0
0
Hello everybody,
In 2012, i install nginx on vps it was working without problem under debian 6
2 weeks ago, my vps stop and my provider no more have debian 6 but 7,
so i install the new version on nginx, but old parameters dont work anymore...

How it did work : when i create a folder under /var/www it is directly accessible
like a subdomaine
for exemple;
i create /var/www/www/index.hml then in web browser i just type
http://www.MYSITE.com
i create /var/www/test/index.hml then in web browser i just type
http://test.MYSITE.com

here script that use to work :

server {
listen 80;
charset utf-8;
source_charset utf-8;

server_name ~^(?<user>.+)\.MYSITE\.com$;
root /var/www/$user;
return 301 http://~^(?<user>.+)\.MYSITE\.com$request_uri;

index index.html index.php;

}

Reverse Proxy: Dissimilar URL's (no replies)

$
0
0
So I know how to reverse proxy http://outside/foo to http://inside/foo. How do I reverse proxy http://outside/foo to http://inside/bar? Here is my attempt that does not work:

bbCode doesn't seem to work here, and Google doesn't help me to figure out how to insert a code block into Phorum.

location ^~ /Foo {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirectoff;

proxy_pass http://inside-IP/Bar/;
}

NGINX redirection Problem - Please help me (2 replies)

$
0
0
Hello everyone,

I am new to Nginx and this forum so I hope you can help me out.
I am curently developping a website made out of multiple site.
I have 3 independant wordpress sites that are all link via landing page.

The structure is as follow

User goes to www.maindomain.com and end up on a landing page.
From there, they can access 3 sites (by clicking on image). The links to the images goes to

restaurant.maindomain.com
hotel.maindomain.com
winery.maindomain.com

The roots of the sites are:
/www/webs/maindomain_com/live/main
/www/webs/maindomain_com/live/restaurant/httpdoc
/www/webs/maindomain_com/live/hotel/httpdoc
/www/webs/maindomain_com/live//winery/httpdoc

In the DNS i have set the 3 subdomain as well as the main domain.

The problem that I have is how do I create my 4 server block so that when Nginx see subdomain.maindomain.com, it uses the root directoy for that website.

Hope I explained it correctly.

Thank you all in advance

Fred

NGINX 1.7.2 reverse proxy cache update (no replies)

$
0
0
Dear all,

Just setup Nginx 1.7.2 as a reverse proxy to proxied backend server.
I have problem about cache content updating. Can I force Nginx to
update cache content ( maybe just one page )via CTRL-F5 function key in browser with my backend server?

Or is there any way to do that?

Thanks

NGINX as some sort of token server. (2 replies)

$
0
0
Hi guys,

I'm wondering if there is any way to configure nginx to be some sort of token server for some urls.
Let me give you an example. There are number of requests to the url like post.php. Some of them are actually spam requests and abuses. Is there any way to do something like when the user accesses post.php nginx displays a "token site" which basically says "Please click here to continue". Based on the click it forwards you to the desired destination.

Thank you for your help!

Always load index.html (no replies)

$
0
0
Dear forum members,

Please help with a silly question. How to always load index.html? When using php, i use this:

location /static/ {
if (!-e $request_filename) {
return 404;
}
}
location / {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /path/to/index.php;
}

Now i need the same setup, just without PHP... Google did not help. Is try_files the right way? I can not figure out how to use it properly to _always_ load index.php regardless of the url/path accessed.
Thank you very much.

Pass arguments to auth_request module from nginx (1 reply)

$
0
0
I want to protext a live HLS stream. I want to use the auth_request module. I want to check if a request is valid by passing a key. So something like: http://domain.com/hls/stream.m3u8?key=xxxxxxx

I have the following setup in nginx.conf:
location /hls {
alias /tmp/hls;
auth_request /hls/auth;
}

location /hls/auth {
proxy_pass http://localhost.com:8080/on_play.php;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}

Now I need to get the key=xxxxx available in http://localhost.com:8080/on_play.php.

I tried a lot but nothing seems to work. I also tried something like:
location /hls {
alias /tmp/hls;
auth_request http://localhost.com:8080/on_play.php?key=$arg_key;
}

But this also doesn't work. There seems not to be a possibility as of to get the key argument in the on_play.php

The $_SERVER["REQUEST_URI"] also doesn't contain the args.

Reverse proxy redirect to postfix in URL (no replies)

$
0
0
Hi

I'm completely new to Nginx and haven't had any success setting up the reverse proxy. What I need to do is redirect URLs of the form http://abcproxy.com/foo/bar to http://foo/bar. What I have right now is
server {
server_name abcproxy.com;
location / {
rewrite ^ scheme:/$uri? redirect;
}
}

I would really appreciate some help in setting this up.

Thanks

Setting up nginx for streaming with SSL (1 reply)

$
0
0
Hi,

I figure this is supposed to be a basic simple task, but there are a lot of things that just do not make sense, and I've tested with Apache and Lighttpd to ascertain the problem lies with nginx. All I am trying to do is setup an extremely basic nginx streaming server with SSL/TLS support. Not looking for RTMP or anything advanced, just something that works. My idea was simple, install nginx with mp4 enabled, put mp4s in a folder, and voila, everything should work, but it isn't. If I go without SSL/TLS, most of the issues go, most of the time, but majority of the time, I cannot stream the videos using an application like VLC, but, I can download the file, which is not my preferred way of doing things.

This is my nginx config.

# HTTPS server
#
server {
listen 443 ssl;
server_name localhost 127.0.0.1;
access_log /var/log/nginx/access_s.log;
error_log /var/log/nginx/error_s.log;

ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;

ssl_session_cache shared:SSL:5m;
ssl_verify_client off;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {

root /path/to/videos ;
# index index.html index.htm;
mp4;
limit_rate_after 100m;
limit_rate 5m;
mp4_buffer_size 4M;
mp4_max_buffer_size 10M;
autoindex on;
allow all;
keepalive_timeout 65;
keepalive_requests 200;
reset_timedout_connection on;
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
gzip off;
expires 30d;
add_header Cache-Control public;
}
}
}

Problem 1: Files don't always play. Some play, some don't and I can't find a pattern to point to a specific problem. I have tried avis, movs, mkvs, flvs and some play and some don't. I have checked permissions, but that isn't it.

Problem 2: There is a weird problem with how nginx is presenting files and folders that doesn't seem to make sense. In the error log, I get an error like this

2014/06/29 16:01:49 [error] 2060#0: *580 open() "/path/to/files/series_a/series_aS02" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /path/to/files/series_a/series_aS02 HTTP/1.1", host: "127.0.0.1"

The player I am using is configured to recognise the folders as /path/to/files/series_a/S02 and when tested with Apache, or Lighty, it recognizes this without any issues. This problem is persistent with SSL and without and I have recompiled twice and pulled from repo to make sure the fault is not on my end, and it isn't.

Anyone know how to fix this?

Thanks.

Ngninx 1.1.19, SSL certificates, Chaining and custom CA (1 reply)

$
0
0
Hello everyone,

I am using nginx 1.1.19 with HTTPS on a debian machine and I'd like to use a chain of certificates.
I cannot upgrade nginx to the current stable release ( problably that's my real problem... ) and I'd like also to build my own CA root.

I created all the certificates, installed them on the debian machine; checked them with "openssl verify" with success.

I followed the instructions from these sites:
http://nginx.org/en/docs/http/configuring_https_servers.html
http://www.digicert.com/ssl-certificate-installation-nginx.htm

But every time I try to use HTTPS from a client nginx explode with the following error:
"SSL_do_handshake() failed (SSL: error:14094412:SSL routines:SSL3_READ_BYTES:sslv3 alert bad certificate) while SSL handshaking, client: 192.168.0.78, server: localhost"

The problem disappears If I just use a single self-signed certificate.
It seems on v1.1.19 I am not allowed to use a custom CA even if it's correctly configured on openSSL.

Any advice or Hint ?

nginx default page configuration (1 reply)

$
0
0
We have nginx setup which is used as a reverse proxy connecting to an apache backend. We are using varnish between them for caching. We need to set a default landing page if only domain name is given. we don't wish to set the index page on apache, we want to do it explicitly on nginx.

We know a method where the nginx can serve the default page from the local directory. What we want to achieve is to set the default page which is present on the apache server only.

Any ideas ?

Regards,

Viral

Multiple (Nested) Codeigniter apps not working in NGINX (no replies)

$
0
0
We've setup 2 CodeIgniter apps which has its own complete code bases on its own directories as in this example. Plus we also have wordpress blog on the same public_html directory.

public_html/HOME_APP
public_html/admin_tool/ADMIN_TOOL_CODES
public_html/blog/WORDPRESS_CODES
HOME_APP codes (CodeIgniter) and our WORDPRESS works fine. But the admin_tool (CodeIgniter) doesn't work. We can access only the http://example.com/admin_tool/index.php but not any inside controller pages. When accessing its show 404 error page. And it looks like the routes are handled via APP1

The nginx rules are as follows. Appreciate if anyone can help us to fix the issue with admin_tool

server{
listen 80;
root /home/ubuntu/websites/example.com/public_html;
index index.html index.htm index.php;
server_name example.com;
access_log /home/ubuntu/websites/example.com/logs/access.log;
error_log /home/ubuntu/websites/example.com/logs/error.log error;

location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}

location / {
index index.php;
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}



location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

}

location ^~/admin_tool/ {
root /home/ubuntu/websites/example.com/public_html/admin_tool;
index index.php;
try_files $uri $uri/ /index.php$args;
}

disabling gzip if etag exists in proxy_pass response (no replies)

$
0
0
Hi,

I'm new to nginx.

Is there a way to disable gzip if proxy_pass reutrns the ETag header.

I.E:
gzip on;
.
.
.
location /foo/bar {
proxy_pass http://server:123;

if ($upstream_http_etag) {
gzip off;
}
}

Basically I'm looking for a workaround to this bug that will disable the gzip compression if server responded with etag header.

http://trac.nginx.org/nginx/ticket/377

Thank you,
Vitaly

Forward proxy preserving the domain (no replies)

$
0
0
[Cross-posted via the forum from the mailing list - http://forum.nginx.org/read.php?2,251449]

Basically, I want to set up a proxy running on example.mydomain.com that will take any URI, retrieve `example.com$request_uri`, and pass it on to the client, preserving my example.mydomain.com domain for the client.

So far I have this config:

server {
server_name example.mydomain.com;
location / {
resolver 8.8.8.8; # why exactly is this necessary?
proxy_pass http://example.com$request_uri;
}
}

It works, but what happens is that nginx returns a `HTTP/1.1 301 Moved Permanently` response, with `Location` set to http://example.com$request_uri. How is this different from the rewrite directive, or from `return 301 http://example.com$request_uri` ?

I want instead a straight response of the actual contents at http://example.com$request_uri. How can I do that?

Excluding some URIs from SSL traffic (no replies)

$
0
0
i would change my nginx config so i could make non-SSL requests over certain URIs. Per example, when i request normal http to [host][certain-uri], avoid redirecting to https.

My current nginx.conf:

worker_processes 1;

user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;

events {
worker_connections 1024;
accept_mutex off;
}

http {
include mime.types;
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;

upstream app_server {
server unix:/tmp/gunicorn.sock fail_timeout=0;
# For a TCP configuration:
# server 192.168.0.7:8000 fail_timeout=0;
}

server {
listen 80;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
client_max_body_size 4G;
server_name _;

ssl_certificate /home/ubuntu/ssl_certificate/mnopi-cert.pem;
ssl_certificate_key /home/ubuntu/ssl_certificate/mnopi-key.pem;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;

keepalive_timeout 5;

# path for static files
root /home/ubuntu/mnopi/mnopi/static/;

location /server-status
{
stub_status on;
access_log off;
allow all;
#deny all;
}


location /static {
alias /home/ubuntu/mnopi/mnopi/static;
}

location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}

location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Forwarded-Protocol $scheme;

proxy_pass http://localhost:8080;
}

location = /favicon.ico {
root /home/ubuntu/mnopi/;
}

location = /ping.gif {
root /home/ubuntu/mnopi/;
}

# error_page 500 502 503 504 /500.html;
# location = /500.html {
# root /path/to/app/current/public;
# }
}
}


Thanks in advance.

Changing configuration paths (3 replies)

$
0
0
Hello, the documentation says "nginx/Windows uses the directory where it has been run as the prefix for relative paths in the configuration."

I am writing a program a program that launches nginx. Therefore it uses my applications path which is a problem.

Is it possible to set the path manually?
Viewing all 2931 articles
Browse latest View live


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