w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Nginx proxy pass and url rewriting
The 1st way that I know of is using a regex against the $args parameter like so: if ($args ~ "^(w+)=") { Or the 2nd way is to use the convenient $is_args like so: if ($is_args != "") { Remember that in both styles you need to put a space between the if and the opening parenthesis; "if (" not "if(" as well as a space after the closing parenthesis and the opening brace; ") {" rather than "){". Full example using the 1st style above, nginx.conf: location ~^/static/photos/.* { include /etc/nginx/proxy.conf; if ($args ~ "^(w+)=") { rewrite ^/static/photos/(.*)$ /DynamicPhotoQualitySwitch/photos/$1 break; expires 7d; proxy_pass http://foofoofoo.com; } } Full example using the 2nd style above, nginx.conf: location ~^/

Categories : Nginx

nginx and trailing slash with proxy pass
Did you already try playing with server_name_in_redirect? However, I found you question via google because I run the same issue with the trailing slash. Nginx forces a 301 to the same URL with an trailing slash.

Categories : Http

nginx proxy pass to sslv3 upstream
Have you tried "ssl_ciphers ALL;"? Although that's not recommended (because that allows weak ciphers), that shall narrow down the scope of the problem. If that doesn't work, most likely the cause of your problem is that the openssl you use doesn't have the suitable ciphers to complete the SSL handshake with your Go server. Note that Go's tls package is only "partially" implemented and the supported ciphers is very limited. There are two solutions: You'll have to upgrade your openssl version that supports what Go's tls package already implemented. And then, of course, recompile your nginx. You'll have to patch tls package to support whatever your current openssl ciphers provides by adding the appropriate suite ids to cipherSuites in tls/cipher_suites.go (I think)

Categories : Ssl

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

jQuery each function returning "Converting circular structure to JSON" error, used with $.proxy
Turns out this was the product of an un caught syntax error. Instead of $.each(JSON.parse(jsonString).data,$.proxy(function(index,value){ alert(JSON.stringify(value)) }),this) I needed: $.each(JSON.parse(jsonString).data,$.proxy(function(index,value){ alert(JSON.stringify(value)) },this))

Categories : Jquery

NGINX Proxy to Cloudant
I found the issue. The innocuous looking rewrite rule as the first line rewrites the $request_uri and changes the $uri variable as part of request fulfillment. $request_uri is not changed by rewrite. So when I included that variable in the proxy_pass location, I was not properly including the edited url with the /couchdb/ removed. Changing the proxy_pass line to: proxy_pass http://myusername.cloudant.com$uri; Now works without issue. This was not an SSL problem nor a problem with Basic Authentication nor other http header issue nor a problem with Cloudant. This was all related to the URI I was forwarding my request to.

Categories : Nginx

How to test nginx proxy timeouts
According to the docs the connect timeout cannot be more than 75 seconds, which may explain why it's timing out sooner than you expected. Not positive, however. I've never really done work with the low-level python sockets library so it may be accepting the connection into the pool at a low level before you actually call s.accept() in your program. Send timeout works by measuring time between two chunks of data heading towards the upstream server. Since you're sending the entire response in one chunk I'm guessing in your implementation you're hitting the read timeout again, rather than a send timeout. If you send one chunk, then wait past the send timeout to send the rest of the response and close the connection, you should hit the send timeout.

Categories : Python

How to move redmine to a sub-URI with nginx as a proxy
This is a pretty complicated thing to do. You wouldn't think so but it is. Every single redmine version that comes out has a different set of correct and incorrect ways of accomplishing this. For example, I have a working configuration with (nginx-1.4.1, unicorn, redmine-2.2.1) but now that I'm using (nginx-1.4.2, unicorn, redmine-2.3.3) that doesn't seem to work anymore. Here's some links that may be of use: http://www.redmine.org/issues/11881 http://www.redmine.org/issues/12102

Categories : Ruby On Rails

Gitlab 5.3 behind nginx reverse proxy
Assuming that the git daemon and the nginx daemon are on the same box I believe that the location block should be like the following: location ^~ /git/ { proxy_pass http://127.0.0.1/git; proxy_redirect http://127.0.0.1/git/ /git; 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; }

Categories : Nginx

Nginx proxy redirect without changing url
first you're using 8000 in proxy_pass, but you're mentioning your port is 8080. Second, remove the rewrite line should do the trick, because youre actually using the rewrite rule here and never get to the proxy_pass line. Something like the following should work: location /assets/ { include proxy_params; proxy_pass http://127.0.0.1:8080; } There are also proxy_rewrite and proxy_redirect commands which might help you in getting this upstream-redirect handled internally by nginx. Hope that helps!

Categories : Nginx

How can I optimize this nginx proxy cache configuration?
A nested location is the right way to create locations with regular expressions and it should do the trick for what you want to achieve. location / { proxy_pass http://192.168.12.12:91; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location ~* .html$ { proxy_cache cache_one; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid any 1m; expires 1m; } } I’m not totally sure if the nested location is really using the options from the outer location block. If it doesn’t (I can’t test this right now) you could create separate files. location / { include proxy.conf; location ~* .html$ {

Categories : Linux

How to configure proxy servers with puppet nginx?
Use nginx::resource::vhost The source of the repo you are using gives a breakdown of the commands you will need to use: https://github.com/puppetlabs/puppetlabs-nginx/blob/master/manifests/resource/vhost.pp

Categories : Nginx

nginx proxy based on host when using https
according to http://www.informit.com/articles/article.aspx?p=1994795, you should indeed have two "server" sections, with two different server names. In each one, you should include your ssl_* directives.

Categories : Ssl

nginx websocket reverse proxy configuration
This issue is related with the nginx version. Pleas check nginx -v, to check your version. The followings params are supported after the 1.4 version. # WebSocket support (nginx 1.4) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; If you are using ubuntu you can install a newer version with this steps: First remove the old version (http://askubuntu.com/questions/235347/what-is-the-best-way-to-uninstall-nginx): sudo apt-get remove nginx sudo apt-get purge nginx sudo apt-get autoremove Then install a new version (https://launchpad.net/~nginx/+archive/development): sudo add-apt-repository ppa:nginx/development sudo apt-get update sudo apt-get install nginx

Categories : Nginx

When using NginX as a reverse proxy, how can i fallback to a maintenance url?
are you using the free version ? I think what you are looking for is in the non-free version called NGINX Plus. Advanced Load Balancing Application Health Checks

Categories : Nginx

NodeJS working behind Nginx
You might want to try to set up the proxy_pass directive without a trailing URI part '/', like this: proxy_pass http://backend; If you specify the URI, it'll be used in the request sent to your backend node.js app. Instead of a request for /room/create, node.js will get a request for / as defined by your proxy_pass setting. For more information, please see the nginx proxy_pass documentation: http://wiki.nginx.org/HttpProxyModule#proxy_pass

Categories : Javascript

Nginx as reverse-proxy: serving files without extension
The problem is, that you need something to identify the files without any extension. A sub-directory or something that’s always present within the request. Your regular expression only matched for requests that start end end with a dot (e.g. http://example.com/.). The following server configuration assumes that all URLs start with storage, as this would be the only possibility to identify those files. Please note that I’m using the try_files directive to rewrite the internal path where nginx should look for the file. The root directive is not meant for what you want to achieve. And last but not least, you should always nest location blocks with regular expressions. There is no limit in the nesting level. nginx will create some kind of tree data structure to search for the best matchi

Categories : Nginx

502 Bad Gateway in node + nginx proxy setup on Heroku
I am not really familiar with Heroku, and pretty new to Nginx, but I'll give it a shot: To me it looks like the Nginx-config is saying that Nginx and the node.js app are using the same port (<%= ENV['PORT'] %>). What you want is Nginx to listen to incoming connections (usually port 80), and have it forward them to the node.js app. Here is an example Nginx config: # the IP(s) on which your node server is running. I chose port 4000. upstream xxx.xxx.xxx.xxx { #Your IP adress as seen from the internet server 127.0.0.1:4000; #Your local node.js process } # the nginx server instance server { listen 0.0.0.0:80; #Have Nginx listen for all incoming connections on port 80 server_name my-site; access_log /var/log/nginx/my-site.log; location / { proxy_set_header X-Real-IP $remote_addr; proxy_s

Categories : Node Js

Find and Replace with Nginx Reverse Proxy setup
It's not ideal, as really the source should be rewritten, but you can use sub_filter to rewrite the content of responses for proxied requests. With your example this would be: location /something { ... sub_filter '(111) 123-4567' '(222) 765-321'; sub_filter_once off; } The default behaviour of this is to replace once (which I have disabled in the example) and to only apply the changes to html pages (this is based on the mime type of the response). This is suitable for using in a reverse proxy as it can replace the Location header with the default options, and links when you disable the sub_filter_once option. While this module is not available unless explicitly configured at compile time, it is my experience that any package manager installed nginx has this option enabled.

Categories : Search

Extract port number from URL and reverse proxy with Nginx
This may be helpful: server { listen 80; server_name test1.test.com; location ~ ^/app/(.*)$ { proxy_pass http://192.168.154.102:$1; } } Notice: If you visit test1.test.com/app/8081, nginx will pass the request to http://192.168.154.102:8081/app/8081. More information about proxy_pass

Categories : Nginx

Nginx: Response handling and Reverse Proxy with Cache
Actually, location.capture is not designed to do things you doing, but, if I get you correct (you want to send headers that browser send you to subrequest) you, probably, can hack it around using ngx.ctx + set ;) But I'd say it is a very dirty kludgy way.

Categories : Nginx

Nginx(proxy) + Apache: two process listening same port
Your problem is simple, you seem to have both nginx and apache listening on port 80, so nginx finds the port already in use, you need to move apache to another port, like 81 for example, and make nginx listen on 80, because it's the one which is going to receive the http requests and proxy it.

Categories : Linux

Proxy a Flask app running on gunicorn to a subpath in nginx
I solved my problem: The snippet http://flask.pocoo.org/snippets/35/ does work, I was so stupid to have absolute URLs in my templates. I changed that to url_for() and now it works like charm.

Categories : Nginx

nodejs get request header from Nginx
by default, nginx's HttpProxyModule has proxy_pass_request_headers enabled, and thus will pass on the client request headers to the destination server. My first suggestions is to try renaming your header to "X-Client-Id" to utilize the extension namespace HTTP has reserved for non-standard headers such as yours and see if nginx will forward that. If not, have a look at the proxy_set_header directive. Side note: using a custom header at all, and specifically one called "client_id" is almost a sure sign you are reinventing the wheel or don't understand industry standards for using cookies and sessions. Unless you are really sure you need this, you may want to step back and rethink your underlying problem.

Categories : Node Js

domain mapping: php or nodejs & nginx
I'm assuming you own example.com, they own mappable.com, and you want to allow them to use their domain mappable.com to access your subdomain mappable.example.com hosted on your server. There are a few steps you'll need to do for this. Set up wildcard DNS with your domain registrar so that all sub-domains will come to your one server. Set up wildcard domain handling in nginx's conf on your one server so that all requests are sent to your code. You can do this using an underscore as the server name to make it the default server. In your PHP code, you can check the headers to determine what domain the request is coming in through. Do a dump of $_SERVER to see what's in there. You will then know if the request came to mappable.com, mappable.example.com, etc... Once you are in PHP with th

Categories : PHP

NGINX Reverse Proxy for upstream Django/Gunicorn Backend
Proxy Buffering Generally proxy buffering is only going to help you if you're generating very big web pages, or sending large files. regardless, it's pretty easy to set up, but you will need to tune the buffer sizes to about the size of your largest pages +20% (Any page that doesnt fit in the buffer gets written to disk), or selectively enable proxy buffering on your largest pages. docs: http://wiki.nginx.org/HttpProxyModule#proxy_buffering Caching I don't know much about your app and how dynamic it's content is, but setting up correct Cache Control/ETAG header generation on your app will be the first thing you'll want to look at. This is what will let Nginx know what is safe to proxy. Also, you may wish to setup multiple cache zones to manage the amount of space your caches take on di

Categories : Django

How do I make nginx proxy some urls on a domain to one location and the rest to somewhere else
You can refer to "rewrite" and "proxy_pass" directive in nginx manual and this can be solved easily: location ~* "^/$|^/(a|b|c).*?$" { rewrite "^/(.*)$" /site/$1 break; proxy_pass http://127.0.0.1:8001; ......; // to add any commands you need break; } location / { proxy_pass http://127.0.0.1:8002; ......; // to add any commands you need break; } Because no rewrite directive wrote in server block, Nginx start to match url in location phase. If is is caught by one location (here using the 1st one as example), then enter into rewrite loop. "break" in the end of rewrite means jump out the rewrite loop. Then start dealing with other directives in this location ,here proxy_pass will be dealt with. General process in this case would be: location match --> rew

Categories : Nginx

nginx/plesk, nodejs+apache - rooting
There is Plesk extension which allows to run Node applications. http://ext.plesk.com/packages/28f799af-1ff4-4bb8-9c87-a04f0f23d32e-jxcore-support

Categories : Apache

Websocket location mismatch when Safari 5.0 connects via nginx https proxy
Nginx websocket proxy only works for RFC6455 compliant handshakes. The older draft 75/76 handshakes, found in Safari 5 and old versions of chrome can't be proxied through nginx. Some more details here: Nginx: Reverse proxying WebSocket Draft 76

Categories : Nginx

Have you managed to make your node nginx proxy setup on Heroku work?
This article contains instructions on setting up nginx as a proxy on Heroku, in conjunction with OpenResty, Lua, and LuaRocks. node.js isn't mentioned. It uses this buildpack. Haven't tried it myself but seems someone has got it working.

Categories : Node Js

mysql-proxy proxy.queries:append call failing with .server_capabilities error
The examples/tutorial-scramble.lua file has a lot of problems - I think it is out of date with the current mysql-proxy. You'll need some constants and another parameter for the proto.to_response_packet call: ... local CLIENT_PROTOCOL_41 = 512 -- New 4.1 protocol local CLIENT_SECURE_CONNECTION = 32768 -- New 4.1 authentication local MYSQL_AUTH_CAPABILITIES = ( CLIENT_PROTOCOL_41 + CLIENT_SECURE_CONNECTION ) ... proxy.queries:append(1, proto.to_response_packet({ username = "connect", response = password.scramble(s.scramble_buffer, password.hash("cpass!1")), charset = 8, -- default charset database = c.default_db, max_packet_size = 1 * 1024 * 1024, server_capabilities = MYSQL_A

Categories : Mysql

nginx reverse proxy to access a backend webcam server that requires 2 ports for the URL
You can use this configuration file Proxy pass server for your first port server { listen 80; server_name localhost; #ssl configuration begin ssl on; ssl_certificate /usr/local/nginx/conf/cert.pem; ssl_certificate_key /usr/local/nginx/conf/cert.key; keepalive_timeout 70; #ssl configuration end #proxy pass proxy_pass http://192.168.1.7:70/url$request_uri;//70 is your first port proxy_set_header X-Real-IP $remote_addr; proxy_set_header Request_Uri_X $request_uri; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } Proxy pass server for your second port server { listen 81; server_name localhost; #ssl configuration begin ssl on; ssl_certificate

Categories : Nginx

How to properly setup nginx as a reverse proxy for gunicorn and flask using subdomains, for both SSL and non-SSL configurations?
server { listen 80 default_server deferred; listen 443 default_server deferred ssl; listen [::]:80 ipv6only=on default_server deferred; listen [::]:443 ipv6only=on default_server deferred ssl; server_name example.com www.example.com testing.example.com; root /path/to/static/files # Include SSL stuff location / { location ~* .(css|gif|ico|jpe?g|js[on]?p?|png|svg|txt|xml)$ { access_log off; add_header Cache-Control "public"; add_header Pragma "public"; expires 365d; log_not_found off; tcp_nodelay off; open_file_cache max

Categories : Python

nginx returning 404 after rewriting to url that exists
This block is matching and interfering: location ~* .(?:ico|svg|css|js|gif|jpe?g|png)$ { expires 3d; add_header Pragma public; add_header Cache-Control "public"; } Even when I made it this, I still had a problem: location ~* .(?:ico|svg|css|js|gif|jpe?g|png)$ { if (-e $request_filename) { expires 3d; add_header Pragma public; add_header Cache-Control "public"; } } I eventually just duplicated some of my rewrite rules in the location that is matching and it works, but I don't understand why. I guess it's just the most specific match and so it ignores the rules in location /. location ~* .(?:ico|svg|css|js|gif|jpe?g|png)$ { if (-e $request_filename) { expires 3d; add_header Pragma public; add_header Cache-Control

Categories : Regex

How to use nginx as reverse proxy to direct localhost:9292 to a sub domain foo.localhost/?
If foo.localhost is your sub domain name and you want to proxy pass sub-domain to main-domain, you can use proxy_pass and you can learn a little more about server directive if needed. An example: server { listem 8080; host sub.main.com; ... location / { proxy_pass http://main.com; break; } } server { listen 8081; host main.com; ... location / { //do something } } This is proxy pass, means when access sub.main.com, actually it finally dealt by main.com, but the client side still shows sub.main.com. If you want client side shows main.com, here should use redirect but not proxy_pass.

Categories : Nginx

Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authorization Required"
You may not need the domain in front of the username. I had a very similar issue, and I fixed it when I removed the domain in front of the username. Since the proxy server is on a domain, I think it implies that your under the same domain.

Categories : Java

My Apache Reverse Proxy is not returning the correct URL when using ProxyPass
Solved: #REDIRECT for http://sysaid.external.com <VirtualHost *:80> ServerName sysaid.external.com ProxyPreserveHost On Redirect / https://sysaid.external.com </VirtualHost> #https://sysaid.external.com <VirtualHost *:443> ServerAdmin webmaster@external.com ServerName sysaid.external.com SSLEngine on SSLCertificateFile /usr/local/etc/apache22/ssl/webmail.external.com.crt SSLCertificateKeyFile /usr/local/etc/apache22/ssl/webmail.external.com.key ProxyPreserveHost On ProxyPass / http://srv-01.internal.local/ ProxyPassReverse / http://srv-01.internal.local/ ProxyPassReverse / http://sysaid.external.com/ </VirtualHost>

Categories : Apache

Nginx+bottle+uwsgi Server returning 404 on every request
Are you sure that NGINX and UWSGI are working properly? Lot's of things could be wrong, I recommend you to follow this guide: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html It's a step by step to setup NGINX and UWSGI with Django but I'm pretty sure you can apply it to any other web app than Django.

Categories : Python

nginx to node.js - pass params
Any parameters will be passed by default and all you need is to handle routing in node it self. Please check out express.js as it allows to define very flexible routes with regexp (if needed). Bear in mind that params in express is different from query data ($_GET in PHP). As query data goes after question mark in URL, but params are defined in routes. For example: app.get('/user/:id', function(req, res, next) { res.send({ params: req.params query: req.query }); // will respond with json object with 'id' }); Then test it, with url: http://example.com/user/23?foo=bar&hello=world It will output: { params: { id: 23 }, query: { foo: 'bar', hello: 'world' } }

Categories : Node Js

Using Lua in nginx to pass a request to FastCGI
Use the ngx.location.capture() method to perform a subrequest to a predefined location block. Then, from within the location block, perform the external, FastCGI request. Because the subrequest itself isn't actually a network operation, but is performed purely within nginx C-based environment, there's very little overhead. Further, because the FastCGI request and other "proxy_pass"-type requests are event-based, nginx can operate as an efficient intermediary. As an example, you could have the following: location / { access_by_lua ' response = ngx.location.capture("/my-subrequest-handler") if response.status == 404 then return ngx.exit(401) -- can't find/authenticate user, refuse request end ngx.say(response.status) '; # other nginx config stuff here as

Categories : Nginx



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.