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

Error page for bad folder request (no replies)

$
0
0
error_page 404 /404.html;

location = /404.html {
root /var/www/;
}

I use the above to catch and direct 404s to a custom 404.html page in /var/www. All my other pages are located in another place. This works fine for catching invalid file request (www.me.net/path1/invalid_file.txt), but doesn't work properly for invalid folder request (www.me.net/invalid_path/). The problem is that I have an image in the custom 404 page and it doesn't show up when erroring on an invalid folder. I guess what I am asking is how do you process bad folder request?

Thanks.

Please help me in URLRewrite using upstream LB servers (no replies)

$
0
0
Hi,

I am new to NGINX and trying to learn at work. I have a requirement, where my web applications are deployed into the two servers at same ports. I am using tomcat server and I want my url args are preserved in final URL.
Example:
Service 1 : http://server1.com:8000/login/blah/blah and http://server2.com:8000/login/blah/blah
Service 2 : http://server1.com:8001/account/blah/blah and http://server2.com:8001/account/blah/blah
Service 3 : http://server1.com:8002/user/blah/blah and http://server2.com:8002/user/blah/blah

and so on. I have 20 services are deployed like above. I am trying to front them with nginx as load balencer and using url rewrite based on the URL context.

Can one help me to resolve the issue. I tried for last 6 hours but nothing is working. I am able solve using urlrewrite but not with proxypass.

nginx.conf file:

#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream loginservice {
least_conn;
server 127.0.0.1:8000;
server 127.0.0.2:8000;
server 127.0.0.3:8000;
}
upstream accountservice {
least_conn;
server 127.0.0.1:8001;
server 127.0.0.2:8001;
server 127.0.0.3:8001;
}
server {
listen 9000;
server_name myserver.com;
rewrite_log on;
location /account{
rewrite ^ $scheme://localhost$request_uri permanent;
proxy_pass http://loginservice;
}
location /logon {
rewrite ^ $scheme://localhost$request_uri permanent;
proxy_pass http://accountservice;
}
}
}

Do I need to build nginx from source and add modules for caching? (no replies)

$
0
0
Im reading a blog about speeding up my wordpress install and it says to use ngx_cache_purge and headers-more-nginx-module

Is this necessary?

How to block access to exchange ecp from external (no replies)

$
0
0
Hi,
I would like to know if anyone knows how i can block access to exchange /ecp from external networks.

I have tried the following conf

server {
listen 80;
server_name mail.example.com;
location ~ ^/(ecp) {
deny all;
proxy_pass http://mail.example.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}


If i do http://mail.example.com i get the nginx default page
If i do http://mail.example.com/ecp i get a http 403 error page which is fine.

If i do the location / { all works fine.

Thanx!!

nginx proxy to subdirectory (5 replies)

$
0
0
Hello, I have a problem with nginx proxy.

I have site on server with IIS at "http://192.168.1.1:80/"
and want to see it at subdirectory like "http://localhost/site1/"

I configure config file as
location /site1/ {
rewrite ^/site1(/.*)$ $1 break;
proxy_pass http://192.168.1.10:80/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
but have a blank page, becouse all css file have get query
to "http://localhost/somecss.css"
insted "http://localhost/site1/somecss.css"

How to fix this?

change the HTTP status code returned when proxy_pass gateway is down (no replies)

$
0
0
Hi
we would like to change the HTTP status code to 200 whenever the backend ("http://example.com/auth") machine behind nginx goes down for some reason.
Is this possible via nginx?

location /files {
auth_request /auth;
set $auth_key $arg_key;
}

location /auth {
internal;
proxy_pass http://example.com/auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Key $auth_key;
}

[Q] Multiple web-services on single webserver (no replies)

$
0
0
Hello!

I want to offer 3 different web-services (Adminer, phpldapadmin, FusionDirectory) on the same webserver.
Any web-service has its own vhost-file.
Any web-service has its own error- and access-file.
All web-services use the same php-socket.

I want to access the different web-services using the same address:
https://<servername>/<webservice>

I can access web-service https://furi/adminer w/o issue, but any other webserver fails with 404. This error is written to Adminer error log, although I'm trying to access phpldapadmin:
2016/03/25 19:33:05 [error] 7415#7415: *8 directory index of "/usr/share/nginx/html/phpldapadmin/" is forbidden, client: 10.0.0.1, server: _, request: "GET /phpldapadmin/ HTTP/1.0", host: "fudir"

Question:
Is it possible setup a webserver as indicated above?

When I define different ports for the different web-services, there are no issues.

THX

How to setup a location to use $_SERVER['QUERY_STRING'] (no replies)

$
0
0
Hello,

I am trying to learn how to use NGINX to use a RESTFUL app, however I had some troubles to find any good tutorial about it. I have configured my site like this:
http://pastebin.com/tTqgRzjn

I would like to pass two parameter to $_SERVER['QUERY_STRING'], for example If I have this url:
index.php/user/myname/

Then, the query string would have two arguments, one of them would be "user" and the second one would be "myname".

I heard that this could be done using fastcgi_params, but I don't know how to use it. I did some searches in Google, but I didn't find any example to do it.

Could you explain me how to do it? Are there multiple approaches or is there only one way to do it? If there are multiple approaches, which one is the best to learn? Is there any book to learn about this?

Best regards.

error 500 when going to wp-admin (1 reply)

$
0
0
I have been trying to setup a new VPS (Ubuntu) with nginx and php7 to host 3 wordpress sites (3 domains). It works mostly, except trying to access the back-end.
When I go to /wp-admin/ I get the login form, but after logging in, the page either just turns blank (with a 500 header) or it shows a 500 error page.
I've been trying to get it to work for 3 days now, so I fear I am getting blind-sighted. I would be grateful if anyone could check my config-files.
I posted them on http://pastebin.com/FrUanYVY
There are 5 files: nginx.conf, default, domain1.com, common.conf and wordpress.conf; I obfuscated all IPs and domain names.
Thanks in advance.

PS: nginx version 1.4.6

Multiple computers running Nginx, each has multiple domains, one router. (no replies)

$
0
0
Hello,

My name is HiM29 and I'm having problems setting up 5 different computers with Nginx under one router.
Each computer uses at least one domain and one computers had 3 domains configured in Nginx.

When I try to assign port 80 from the router to each server the firewall will not work probably and this even had influence on other opened ports.
The firewall probably crashes or refuses to work, I can't confirm this as my router's web interface doesn't allow that much access.

I am thinking of this solution:
Setup a DNS server and assign each domain name a local domain name to each server.
Set the local address of the DNS sever as first choice in the router's DNS configuration and in it's own DNS configuration.
And redirect each request from a domain name to a local domain using Nginx. Each server had access to the outside.

Is this a correct solution/ and is this the best solution?

Yours sincerely,
HiM29

Multiple computers running Nginx, each has multiple domains, one router. (no replies)

$
0
0
Hello,

My name is HiM29 and I'm having problems setting up 5 different computers with Nginx under one router.
Each computer uses at least one domain and one computers had 3 domains configured in Nginx.

When I try to assign port 80 from the router to each server the firewall will not work probably and this even had influence on other opened ports. The firewall probably crashes or refuses to work, I can't confirm this as my router's web interface doesn't allow that much access.

I am thinking of this solution:
Setup a DNS server and assign each domain name a local domain name to each server. Set the local address of the DNS sever as first choice in the router's DNS configuration and in it's own DNS configuration. And redirect each request from a domain name to a local domain using Nginx. Each server had access to the outside.

Is this a correct solution/ and is this the best solution?

Yours sincerely,
HiM29

Point NGINX to Wordpress Docker Port (no replies)

$
0
0
Hi,

I want to point mein website www.example.com to my wordpress docker container. Rigth now my config file looks as follows:

server {
listen 80;
server_name www.example.com example.com;
index index.php index.html;

location / {
proxy_pass http://localhost:8080;
include /etc/nginx/proxy_params;
}

That works but the webserver always rewrites the URL to www.example.com:8080 I don't want it that way. Is there an other way to simply point my website to the wordpress docker port? I also want to force https for at least www.example.com/wp-admin/ how is that possible?

Configure nginx to display another html file when a file is present (no replies)

$
0
0
Hello

I'm new to nginx

I'm attempting to have nginx redirect a request from a URL to another page that display something like "Deploy is in progress" so that the main URL is not available. I need to do this through a file, have nginx check if the file is present and then show the alternative html file.

I've checked the try_files directive but I don't think that's the route to go, could someone please help?

sub domain (no replies)

$
0
0
Hi all,

I must make two websites with Joomla.
So altering the rule that if I call http: // www answer me the first web, and if I call http: // www / site1 answer my second website.

Where can I find a possible configuration?

Thank you

DNS Rewrite Rules Apache To Ngnix Translation , Help (1 reply)

$
0
0
Hi Nginx community


I need you help i use to successfully migrate my site from Apache to Ngnix but i trying to convert some DNS rewrite rules and till now with no success . Can you please give me some translation help .

Rewrites that i wont to translate are :

RewriteCond %{HTTP_HOST} ^domain\.net\.mk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.net\.mk$
RewriteRule ^(.*)$ "http\:\/\/domain\.com\.mk\/$1" [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.mk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.mk$
RewriteRule ^(.*)$ "http\:\/\/domain\.com\.mk\/$1" [R=301,L]


Thanks for you support , where do a need to put translated rewrites in my vhost template or in nginx.conf (single web site on VPS)

Encoding in file included by geo (no replies)

$
0
0
Hi,

I use geo module in nginx 1.8.1. It has several geo directives that include files with IP to geodata mappings.

Unfortunately, the encoding in city and country names is messed up when the variables are sent back as HTTP headers or passed to the backend. The included files are in UTF-8 without BOM.

So, the question is: in what charset should I encode the files that are included by geo directives?

Monitoring Status of tcp/stream proxy (no replies)

$
0
0
Is it possible to use the http_stub_status_module or any other to get metrics from a stream proxy?

How to set up NGINX in Windows (What are the requirments?) (3 replies)

$
0
0
We are working on installing NGINX in Windows that will perform reverse proxy for us to allow users click on an url from their local desktop that will access a page set up in our virtual machine. In between there may be firewall.
URL example: http://hostsite:XX/page XX = port number

Example conf file:
Server {
location /page { proxy_pass http://vmtrueipaddress }
}

Basically user can access http://vmtrueipaddress from their desktop using http://hostsite:XX/page without going into our VM. Our conf file works before, but now we are moving to a new virtual machine.

Question: What are some requirement for this? Do we need to open port "XX" in the firewall to allow communication? Do we need to specific Host name "hostsite"? Right now http://hostsite:XX/page works within our VM, but not from desktop.

Much Appreciate,
Junior App Admin

Display server name (7 replies)

$
0
0
If you put anonusa.net into this ssl lookup site, it shows the 'Server type' in the listing. When I lookup my own site, the server type is not listed. Is there some parameter that you put in the config file that causes the server type to display?
Here is a site that displays it:
https://www.sslshopper.com/ssl-checker.html?host=mixmin.net#hostname=anonusa.net

Thanks

Trailing slash madness (1 reply)

$
0
0
I have Googled and researched and I have recreated my conf file so often and I can't get past this issue with the trailing slash. I really hoping someone can help before I give up and try Apache.

We have a firewall in front of our server so we are allowing HTTPS only. There is no HTTP access.

My conf file:

server {
listen 443;
server_name sub.domain.com;
server_name_in_redirect on;

access_log off;
error_log /var/log/nginx/error.log crit;

ssl on;
ssl_certificate /etc/ssl/cert/cert.crt;
ssl_certificate_key /etc/ssl/cert/cert.key;

ssl_session_timeout 5m;

ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;

location / {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_pass http://192.168.10.202;

proxy_redirect http://192.168.10.202 https:/sub.domain.com;
}
}

The last line is recent.

Here are the results. With a trailing slash:

curl -I https://sub.domain.com/test/
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Thu, 07 Apr 2016 14:01:08 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.5.9-1ubuntu4.14

Without a trailing slash:

curl -I https://sub.domain.com/test
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.6 (Ubuntu)
Date: Thu, 07 Apr 2016 14:02:16 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: http://sub.domain.com/test/

Please note that it introduces a permanent redirect to HTTP rather than HTTPS. Why? How do I stop this behaviour?

I have spent a day on this and there appears to be no single and effective way of solving this issue.

I would be very grateful of any help.

Thanks.
Viewing all 2931 articles
Browse latest View live


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