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

ERROR USING NGINX AS REVERSE PROXY (no replies)

$
0
0
Getting this error using NGINX as reverse proxy. Tried using / as a redirect but it gives error 404 not found. could try to use on any server
the code is attached below.
thanks

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;
upstream myapp1 {
server http://www.google.com;
}
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

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

location /test {

proxy_pass http://myapp1;

}

Nginx reverse proxy redirection (3 replies)

$
0
0
Hi,

I am using Nginx as a reverse proxy and when I login in my web interface I am redirected to the original URL. I would like to avoid it and always keep the "server_name" as URL. Is it possible ?

This is my /etc/nginx/conf.d/my_app.conf :

server {
listen 443 ssl;
server_name my-app.net;
ssl_certificate /etc/pki/tls/certs/my-app.cer;
ssl_certificate_key /etc/pki/tls/private/my-app.key;
ssl_protocols TLSv1.1 TLSv1.2;
access_log /var/log/nginx/my-app.access.log main;

location / {
proxy_pass http://ip_of_the_app:7180/;
proxy_redirect off;
}
}

I connect on the http://my-app.net, then enter login informations and I am redirected to http://ip_of_the_app:7180 at the same login page, then I have to login again.

Can you help me on this case ?

Thanks,

Limit the number of simultaneous connections to an upstream server (no replies)

$
0
0
I am using NGINX as a reverse proxy to an upstream server.

Is there any way that I can limit the number of simultaneous connections NGINX establishes to the upstream server?

The desired behaviour is:

NGINX keeps a maximum of n connections to the upstream
If clients make (n + m) connections then m connections should be queued and submitted to the upstream server as soon as an established connection becomes free.
The NGINX documentation alludes to a couple of parameters in the module ngx_http_upstream_module namely max_conns and queue. The problem is that these parameters are only available in the commercial version of NGINX.

Is there any other way of achieving this behaviour without resorting to the commercial version of NGINX?

Redirect (no replies)

$
0
0
I am wanting to use nginx to redirect cloud.ventureforth.com to https://129.144.5.35/ords/f?p=1000. I also want ot mask the https: redirect. Here is what I have in my config.

server {
listen 80;
server_name cloud.ventureforth.com;

location / {
proxy_pass https://129.144.5.35/ords/f?p=1000;
}
}

When I type cloud.ventureforth.com in the browser, I get cloud.ventureforth.com:1:::::

Any suggestions would be helpful.

500 Internal server error with Suitecrm and Nginx (no replies)

$
0
0
Hi Guys,

Im moving from lighttpd to Nginx, I need to host 2 web applications (mantis and suitecrm) so far I have managed to make it work, but while in suitecrm several link actions trow a 500 Internal error, I have setup files and folders inside the suitecrm to 755 but did not fix the 500 error

Im hosting this on AWS

This is one of the URL that are getting the 500 error
http://ec2-32-1-97-35.compute-1.amazonaws.com/suitecrm/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DACLRoles%26action%3DEditView%26return_module%3DACLRoles%26return_action%3DDetailView


This is my nginx vhost config file

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /var/www;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name *.amazonaws.com;

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

#mantis
location /mantis {
try_files $uri $uri/ =404;

}

#suitecrm
location /suitecrm {
try_files $uri $uri/ /index.php?$args;

}


What Im doing wrong in the suitecrm location?

nginx 1.10.1 with php-fpm: download all files as index.php (or as index.zip by zip downloads) (no replies)

$
0
0
Hi,

i spend now more than for 10 hours on my nginx.conf around and despair slowly :(
My Problem:
If you want to surf on my nginx as web-proxy and want to download a file via a web page, this will always be downloaded as index.php.
File size matches the targeted file size.
My first suspect was that it is up to the activate gzip encoding or wrong mime.types implementation ...
nginx.conf, mime.types, fastcgi_params and an example download-file attached ...

Use php5-fpm, oensuse 13.2 and nginx 1.10.1

Further infos: when the download-file is an zip file the download named index.zip...
i have no idea why :-/

nginx 1.10.1: how to integrate the icap protocoll || a icap client to communicate with sophos icap server (1 reply)

$
0
0
Hi,

I have already done a icap Implementation by squid.
Now I must also implement the icap Protocol || a icap client at nginx.
I can´t not find anything in the forum or on the Web about nginx with icap.
Is the icap Protocol || a icap client integrated as standard in nginx?
If not: Is there an additional module for icap communication or how you would integrate icap?
Maybe I would write a icap-client in python and integrate this as multithreaded daemon, but nginx module would there already be a better solution.
thx for your help
lg

Multiple requests by upstreams (2 replies)

$
0
0
Hello!

How to set up Nginx, so it sent simultaneous requests to different upstream server?

For example:
upstream backend {
     server backend1.example.com;
     server backend2.example.com;
     server backend3.example.com down;
     server backend4.example.com;
     server backend5.example.com;
     server backend6.example.com;
}

And we need to Nginx when requested in 3 parallel query sent to the backend: backend1.example.com, backend2.example.com, backend4.example.com.
Then, if backend2.example.com returned an error, the request was forwarded to backend5.example.com.

If one of the three queries successfully completed, the client receives the quickest response.

The goal - do not waste time repeating the request to the next server from upstream.

How do I get nginx to use a different config file on boot? (2 replies)

$
0
0
I posted this on askubuntu.com and someone told me that this is the best place to post so reposting here:

I'm trying to do something that I consider fairly simple... When Ubuntu boots, I want to start nginx using a config in a non-standard location (e.g. /home/ubuntu/foo/nginx.conf)

I've just installed that latest nginx (1.10.1) and I notice that it starts on boot and if I do "ps ax | grep nginx" I get a list of a bunch of worker process.

I haven't been able to find any standard way for it to not use its default config in /etc/nginx/nginx.conf

I could copy the contents of my .conf file into the standard .conf file and that would solve the problem. I don't what to do that because mine is in source control in its location and it will be updated now and then.

I was thinking of adding an @reboot entry to crontab to stop nginx and then start it with the -c param so that it would pickup my config. However that feels like the wrong solution. i.e. 1. allow Ubuntu to start nginx 2. shut it down 3. restart it with a different config.

Anyone know the answer to this?

(Ubuntu 14.04)

How to serve static in Rails? (1 reply)

$
0
0
It's typical for Ruby on Rails application to store it's static resources in /public/images , /public/stylesheets, /public/javascript subirs. But all of them have the same beginning of URI: /assets/1.jpg /assets/1.css /assets/1.js.

How can I configure Nginx to properly serve such resources?

resource: net::ERR_CONNECTION_TIMED_OUT (8 replies)

$
0
0
Hi all ;). Hope everyone is good. Taking the Chance using the Community for helpfully Info ;).

i'am little bit desperated, as not sure where the Issue is.

i'am using VMware vSphere6 and installed on Centos6 the nginx-1.10.1.

i'am configured the Proxy to listen onto 443 and to pass it to the Webclient ip.

So far so good. First Site working. 2nd gives me the Credential Screen. it's also working. once giving wrong Pass > it's giving me an Authentication Error > so means for me Communiction is working. but once i try to Login with correct pass the Browser is getting the Timed_Out error after about 20Secs. i checked logs. not seeing some Errors. all with Http Status 200. Just seeing strange DYNAMIC Entry next to the /vsphere-client/UI.swf.

i use following Code:

server {
listen 443;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_timeout 10m;
ssl_certificate /etc/nginx/ssl/ca.crt;
ssl_certificate_key /etc/nginx/ssl/ca.key;


location / {
proxy_ssl_certificate /etc/nginx/ssl/ca.crt;
proxy_ssl_certificate_key /etc/nginx/ssl/ca.key;
proxy_pass https://xxxx;
#proxy_read_timeout 200s;
#proxy_connect_timeout 200s;
}


}

Last Message in the Log i see:

"POST /vsphere-client/endpoints/messagebroker/amf HTTP/1.1" 200 1176 "https://xxxxx/vsphere-client/UI.swf/[[DYNAMIC]]/6" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"


i tried to use also with removing the hash in the timeout lines.Maybe something wrong with this Dynamic swf?

for any Help i would be very happy.

Many thx in Advance.

Best regards

Max

location rewrite s3 files (1 reply)

$
0
0
Hi, I have problems solving below case:

All our files that are uploaded to our server are copied to an AWS s3 bucket automatically. This is a repeating process.

We want to delete the original files and rewrite the original urls in the generated html files hosted by nginx

original URL: https://localhost.com/images/sg_profilepics/949/56_output.jpg?t=-62169984000

to be replaced with: http://s3-bucket.aws.domain.com/images/sg_profilepics/949/56_output.jpg?t=-62169984000

1) How to capture the location?
2) How to rewrite the URL's?
3) Can we make the rewrite transparent to the users so they are not aware of the redirect to amazon?

Hope somebody can help because I tried everything but I cant seem to get it working... :-(

404 on WordPress: working at all but non-existent *.php not (no replies)

$
0
0
Hi people,
I'm having a problem on my Nginx installation and WordPress. Even if the WordPress 404 return correctly on every page, on non existent files.php returns the standard Nginx 404 page, not the WordPress one. This is my Nginx configuration file. How can I solve this?

Thanks!

fastcgi_cache_path /etc/nginx/cache/domain.tld/ levels=1:2 keys_zone=domain.tld:100m inactive=60m;

server {
listen *:80;


server_name domain.tld www.domain.tld;

root /var/www/domain.tld/web/;



index index.html index.htm index.php index.cgi index.pl index.xhtml;



error_log /var/log/ispconfig/httpd/domain.tld/error.log;
access_log /var/log/ispconfig/httpd/domain.tld/access.log combined;

location ~ /\.(?!well-known/acme-challenge/) {
deny all;
access_log off;
log_not_found off;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ \.php$ {
try_files /b13d29a00e30846cadcfe27cac5e99c7.htm @php;
}

location @php {
try_files $uri =404;
add_header X-Cache $upstream_cache_status;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php7.0-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_cache domain.tld;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache_valid 200 60m;
fastcgi_intercept_errors on;
}

set $skip_cache 0;

if ($request_method = POST) {
set $skip_cache 1;
}

if ($query_string != "") {
set $skip_cache 1;
}

if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}

if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}

location ~ /purge(/.*) {
fastcgi_cache_purge domain.tld "$scheme$request_method$host$1";
}


location / {
try_files $uri $uri/ /index.php?$args;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~* ^.+\.(css|js|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}

Reverse Proxy IIS Web Applications (1 reply)

$
0
0
Hi. I am trying to setup a reverse proxy in front of an application server that is running IIS. Currently the only way I can get it to fully work
is to use the hostname of the application server. If I try to use a different url, the application breaks internally.

How it breaks. You can log into the main web application and any content that is under the application /APP1 you can see. When one of the links tries to open APP2 in an iframe, the page will not display. Hovering over the link you can see the https://hostname/APP2 instead of https://web.exp.org/APP2. Does anyone have any suggestions as to what I need to do in order to get this to work? I've included a sample basic configuration of what I have right now.

In the sample configuration I have tried to use IP's instead of url's with no change in behavior.

server {
listen 80;
server_name *.exp.org;
return 302 https://web.exp.org/APP1/;
}

server {
listen 443;
server_name web.exp.org;
ssl on;

location / {
proxy_pass https://main.exp.org;
proxy_set_header HOST $host;
proxy_cache one;

}
location /APP1 {
proxy_pass https://main.exp.org/APP1;
proxy_set_header HOST $host;
proxy_cache one;

}
location /APP2 {
proxy_pass https://main.exp.org/APP2;
proxy_set_header HOST $host;
proxy_cache one;
}
location /images {
proxy_pass https://main.exp.org/images;
proxy_set_header HOST $host;
proxy_cache one;
}
}

get Real IP address of user in stream context (1 reply)

$
0
0
Hi. I have this config
stream {
upstream web_server {
server 54.194.65.153.xip.io:443;
}
server {
listen 443;
#proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass web_server;
}
}

I want to get user real ip-address. But if I uncomment #proxy_set_header X-Forwarded-For $remote_addr; I see error

[emerg] "proxy_set_header" directive is not allowed here

How can I get user real ip? Thank you.

Cookie redirect from homepage (no replies)

$
0
0
Hi,

I'm trying to redirect to a different page from homepage based on a cookie. Secondary objective is to also set that cookie. The method works with Javascript but when I try to do if with nginx, it doesn't work consistently.

I have several location rules, but the one that's matched for homepage is
location /
{
try_files $uri $uri/ /cms/assets/cache/supercache/$http_host/$cache_uri/$file /cms/index.php?$args;
gzip_static on;
expires 1d;

add_header X-Test default;
}

The $cache_uri and $file vars are set elsewhere and they work.

Now, for homepage I added this rule:
location = /index.html
{
gzip_static on;
expires 1d;

add_header X-Test root;

if ($cookie_prefer ~* "someval")
{
return 302 /somepage.html?$args;
}
}
Somehow this doesn't work reliably. Crazy as it sounds, it works... sometimes. I suspect a caching issue or something, but it's even more frustrating than if it wasn't working at all.

Am I doing something wrong? Is there a better, fool-proof way for cookie redirect?

Second question is about setting the cookie itself. I know I can add a cookie with add_header but how can I specify the expiration as 1 month from now?

redirection of websites (no replies)

$
0
0
Hi, we have some websites that we would like nginx service to redirect them to an alternative website. everything's setup properly like we've created a cname redirecting to a different website which is setup in nginx as well.

When I ping the website (suppose to be redirected), it detects the nginx server IP, so meaning to say, it is resolving using the nginx server or nginx redirection server. but for some reason it doesn't reaches the alternate website.

Regards,
Thanks

Nginx error -Starting nginx: nginx: emerg unknown “status” variable (no replies)

$
0
0
What I am trying to do using nginx is- to call a backend for authentication and if the response is successful I will redirect to website 1 (for example -google.com) and if authentication fail I will redirect to website2(facebook for example).

Below is my nginx.conf-

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/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 /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/default.conf;
}
The default.conf file is as below -

server {
listen 80 default_server;
server_name _;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
# root /usr/share/nginx/html;
# index index.html index.htm;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://backend_ip_Address;


set $my_var 0;
if ($status = "200"){
set $my_var 1;
}

#if($status = 4xx) {
# set $my_var 2;
#}

if ($my_var = 1){
proxy_pass http://www.google.com;
}

if ($my_var = 2) {
proxy_pass http://www.facebook.com;
}
}

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/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;
}
}
The issue I am facing is when I am trying to execute sudo service nginx restart with this configuration I am getting below error- Starting nginx: nginx: [emerg] unknown "status" variable

The same $status is also present in nginx.conf log configuration and it's logging the response code properly like 301, 200 etc. But the same status variable is not working in default.conf file. Any help on what I am doing wrong?

I tried replacing status with body_bytes_sent header and it's works.

By google search https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=nginx++unknown+%22status%22+variable only related information is https://www.drupal.org/node/2738983 but no much help to resolve this.

Not collecting chunked message (no replies)

$
0
0
I have one endpoint with 80/443 ports open. And in 443 port on some path (like /jms) have JMS service that works via http using chunked encoding for making connection alive for a long time (I know, that's a ugly hack).
As far I know chucked messages are collecting in simple packet. How to proxy it chunk by chunk and dont close the connection?
I think tcp proxy on custom path in server can solve my problem.I tried community module https://github.com/yaoweibin/nginx_tcp_proxy_module but it didn't worked as I want.

ssl_session_cache question (no replies)

$
0
0
Hey! I have a question. Suppose we have server with multiple SSL sites. We use SSL cache. What is appropriate way to do it?

a. Global ssl_session_cache in http section like:
ssl_session_cache shared:SSL:50m;

or

b. Local ssl_session_cache in server sections like:

server {
..
ssl_session_cache shared:SSL1:10m;
..
}

NOTE: Different servers, different keys.

Thanks!
Viewing all 2931 articles
Browse latest View live


Latest Images

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