Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
(https)Nginx --> (http)Play!. But request.secure is false | Configured Nginx as reverse proxy in front of Play! and passing https
with the following headers set :-proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl https;login()[https://localhost/login] is being forwarded to Play! on port
9000 as 'http'. But request.secure in login() is sti... | the second entry is wrong, it should be:proxy_set_header X-Forwarded-Ssl on;That will solve the issueUPDATE: without being able to test, the only thing I see missing is this header:proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;Besides that, everything seems correct. |
Is HTTPS behind reverse proxy needed? | I have an API server running behind an nginx reverse proxy. It is important to have all requests to my API server be secured via TLS since it handles sensitive data.I've setup nginx to work with TLS (LetsEncrypt) so that seems to be okay. However, requests from nginx to my API server are still insecurehttprequests (thi... | It all comes down to how secureor paranoidyou'd like your implementation to be. It may also depend on the type of data you're playing with. For instance: I'd definitely do this for credit card numbers or other sensitive information.Asthecommentshave already stated, you would typically terminate SSL connections at the f... |
Should nginx be packed into the same container as Django when deploying with Docker Swarm? | We are looking to move our current Nginx/Gunicorn/Django stack into Docker, and deploy it for high availability using Docker Swarm. One of the decisions we have been struggling with is whether or not to place Nginx in the same container as Gunicorn/Django. Here are the scenarios and how we view them:Scenario 1: Place N... | Based on production experience, it's better to counterpart rule from docker docsone container for one process. You're shipping a (micro-)service with docker image, and if it's required to have nginx in it, you include it.So basically for django app there are:nginx (e.g.: for static files)gunicorn or uwsgidjango code it... |
nginx/apache/php vs nginx/php | I currently have one server with nginx that reverse_proxy to apache (same server) for processing php requests. I'm wondering if I drop apache so I'd run nginx/fastcgi to php if I'd see any sort of performance increases. I'm assuming I would since Apache's pretty bloated up, but at the same time I'm not sure how reliabl... | nginx will definitely work faster than Apache. I can't tell about fastcgi since I never used it with nginx but this solution seems to make more sense on several servers (one for static contents and one for fastcgi/PHP).If you are really targeting performance -and even consider C/C++- then you should give a try to G-WAN... |
iOS 12 wkwebview not working with redirects? | I have a basic webview that loads a website that is fronted by an nginx reverse proxy that is just forwarding it to another site. I am able to load it using safari, chrome firefox etc on the device and emulator (as well as computer), but when I try to load it in the wkwebview it flashes a couple times then goes to a b... | I had the same problem and I solved it this way through the WKNavigationDelegate:func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated {
guard let url = na... |
NGINX/PHP downloading instead of executing | I have an NGINX server with fastcgi/PHP running on it. I need to add userdirs to it, but I can't get PHP to execute the files - it just asks me if I want to download it. It does work without the userdir (e.g. it works on physibots.info/hugs.php, but not physibots.info/~kisses/hugs.php).Config:server {
listen 8... | It turns out that it was linking to /home/foo/public_html/~foo. So, a circular symlink from /home/foo/public_html/~foo back to /home/foo/public_html works like a charm. Thanks for all your help! |
Gorilla WebSocket disconnects after a minute | I'm using Go (Golang) 1.4.2 with Gorilla WebSockets behind an nginx 1.4.6 reverse proxy. My WebSockets are disconnecting after about a minute of having the page open. Same behavior occurs on Chrome and Firefox.At first, I had problems connecting the server and client with WebSockets. Then, I read that I needed to tweak... | I had the same issue, the problem is the nginx configuration. It defaults to a 1 minute read timeout forproxy_pass:Syntax: proxy_read_timeout time;Default: proxy_read_timeout 60s;Context: http, server, locationSeehttp://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeoutIn my case I've increased the ... |
How do I install php mbstring extension in to Nginx Ubuntu | I need this php extension in order to use one of my Magento extension.
How do I install php mbstring extension to my Nginx Ubuntu 14.04? | EDIT: See Ajeets answer below for the correct solutionI don't think mbstring (like OpenSSL) depends on an extension, it should just be built into PHP. I'm running Raspbian and NginX and if I create a file withand look at it then I see: |
nginx configuration for Laravel 4 | I am trying to setup my Laravel 4 project using nginx . Here is my nginx server block for laravel :server {
listen 80;
root /home/prism/www/laravel/public;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.p... | This is an NGINX Configuration i've used with Laravel 4 and Laravel 4.1 that works.server {
listen 80;
server_name sub.domain.com;
set $root_path '/var/www/html/application_name/public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewr... |
nginx location regex - character class and range of matches | I am trying to setup a regex for the path/s/<4-6 character string here>where I capture the 4-6 character string as $1.I tried using the following two entries, but both faillocation ~ ^/s/([0-9a-zA-Z]){4,6}+$ { ...
location ~ ^/s/([0-9a-zA-Z]{4,6})+$ { ...The first one comes up with 'unknown directive' and the second c... | If you want to capture 4 to 6 characters, why you don't have put the quantifier inside the capture parenthesis?Something like that perhaps:location ~ "^/s/([0-9a-zA-Z]{4,6})$" {...Curly braces are used both in regex and for block control, you must enclose your regex with quotes (single or double) (<-- wiki nginx) |
nginx custom error page 502 with css and image files | I'm trying to add a custom error page for 503. I added these lines to server conf in nginx.conf file:error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/username/sites/myProject/current/errorPages;
internal;
}It displays the custom page when uwsgi is down, however this doesn't show any imag... | I just had the same problem, and what did work is setting the nginx conf like this :error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/username/sites/myProject/current/errorPages;
}
location = /image.png {
root /home/username/sites/myProject/current/errorPages/50x_files;
}And then reference th... |
Kubernetes nginx ingress controller cannot upload size more than 1mb | I am fairly new to GCP and I have a rest URI to upload large files.I have a ngress-nginx-controller service and want to change it to upload files larger than 1mb and set a limit.apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":... | If you need to increase the body size of files you upload via the ingress controller, you need to add an annotation to your ingress resource:nginx.ingress.kubernetes.io/proxy-body-size: 8mDocumentation available here:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-max-body-... |
Nginx (13: Permission denied) while connecting to upstream | I'm deploying my Djano application on a VPS and I'm following the steps in the below link to configure my app with Gunicorn and Nginx.How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 16.04Everything went well with the tutorial (gunicorn and nginx are running) but the issue is that when Im' visiting the... | After searching for roughly 7 hours, I was finally able to find a solution to this issue in the Nginx forum:Nginx connet to .sock failed (13:Permission denied) - 502 bad gatewayWhat I simply did was changing the name of the user on the first line in/etc/nginx/nginx.conffile.In my case the default user waswww-dataand I ... |
Is it possible to deny range of IPs on Nginx | Is it possible to deny range like 43.249.64.0-43.249.85.255? Or only by mask like 43.249.64.0/19 which includes up to 43.249.95.255 which makes it not good decision. | You can block IP ranges using theCIDR notation. Have a look at the article 'Nginx Block And Deny IP Address OR Network Subnets'You can useIP range calculators like this onethat do the math for you. For example your range '43.249.64.0-43.249.85.255' can be expressed as:43.249.64.0/2043.249.80.0/2243.249.84.0/23 |
Using nginx to simulate slow response time for testing purposes | I'm developing a facebook canvas application and I want to load-test it. I'm aware of the facebook restriction on automated testing, so I simulated the graph api calls by creating a fake web application served under nginx and altering my /etc/hosts to point graph.facebook.com to 127.0.0.1.I'm using jmeter to load-test ... | You can slow the speed of localhost (network) by adding delay.Useifconfigcommand to see network device: on localhost it may beloand on LAN itseth0.to add delay use this command (adding 1000ms delay onlonetwork device)tc qdisc add dev lo root netem delay 1000msto change delay use this onetc qdisc change dev lo root nete... |
cURL Multi Threading with PHP | I'm using cURL to get some rank data for over 20,000 domain names that I've got stored in a database.The code I'm using ishttp://semlabs.co.uk/journal/object-oriented-curl-class-with-multi-threading.The array $competeRequests is 20,000 request to compete.com api for website ranks.This is an example request:http://apps.... | This one always does the job for me...https://github.com/petewarden/ParallelCurl |
Compressing rails assets and nginx gzip | Do I have to configure nginx to compress assets (gzip set to on) if I have compressed rails assets withrake assets:precompile? I mean does it make sense or not? Will performance better or worse? Thank you! | No, you do not. They are not the same kind of compression. When you runrake assets:precompile, all you're really doing is joining a bunch of files into one file and dumping it to the disk. Actually, according to theofficial documentation, it is two files:When files are precompiled, Sprockets also creates a gzipped (.gz... |
Nginx proxy https to http on non standard port? | I have nginx configured to proxy https traffic to an http server running on the same machine.Everything works fine when I configure nginx to listen on / proxy from https port 443. But I really want to listen on a non standard port. When I configure a non standard port, nginx receives the request and sends it to my http... | The issue stems from the line -proxy_set_header Host $host;Your web server(WEBrick) in turn is including this when issuing the redirect response.You can change it to include the non-standard port -proxy_set_header Host $host:$server_port;which should resolve this. |
Why use Apache over NGINX/Cherokee/Lighttpd? | Apache has been the de facto standard web server for over a decade, but recent years have brought us web servers that consume less RAM and handle many more requests per second using fewer threads and asynchronous i/o. In my opinion, I also find the configuration of these servers to be more straightforward and minimal.W... | Apache's .htaccess provides flexible configuration. This allows users on a shared host to customize certain settings of an apache without having to alter the core apache configs.It is the standard server bundled in typical LAMP setups, although, many services use other web servers for in conjunction (like static files,... |
Under tornado v4+ WebSocket connections get refused with 403 | I have an older tornado server that handles vanilla WebSocket connections. I proxy these connections, via Nginx, from wss://info.mydomain.com to wss://mydomain.com:8080 in order to get around customer proxies that block non standard ports.After the recent upgrade to Tornado 4.0 all connections get refused with a 403. W... | Tornado 4.0 introduced an, on by default, same origin check. This checks that the origin header set by the browser is the same as the host headerThecode looks like:def check_origin(self, origin):
"""Override to enable support for allowing alternate origins.
The ``origin`` argument is the value of the ``Origin`... |
How to deploy Ruby Rack app with NGINX | I want to deploy a simple Ruby Rack service with NGINX. I read various things on the internet, none of which were helpful enough. Lets say I have this (in reality it's a bit more complex but still < 200 lines of code service):require 'rack'
class HelloWorld
def call(env)
[200, {"Content-Type" => "text/plain"}, [... | here is a basic nginx config for the case you are going withunicorn/thinsolution:upstream rack_upstream {
server 127.0.0.1:9292;
}
server {
listen 80;
server_name domain.tld;
charset UTF-8;
location / {
proxy_pass http://rack_upstream;
proxy_redirect off;
proxy_set_header Host ... |
Nginx error pages not working | I have the following vhost entryserver {
listen 80;
server_name example.com www.example.com;
#access_log /var/log/nginx/nginx-access.log;
location /media/ {
root /home/luke/django/solentcms;
}
location /admin/media/ {
root /home/luke/virts/django1.25/lib/python2.7/site-pac... | Are the errors coming from your backend? You may need to addproxy_intercept_errorson; alongside your proxy_pass. |
access denied on nginx and php | Using nginx web server and php. nginx is working, I see 'Welcome to nginx!' but I get 'access denied' when trying to access a php page. I also installed php-fastcgi.Here is my nginx default conf:# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
... | Do like this where you have your secondary locationlocation / {
try_files $uri $uri/ =404;
root /path/to/your/www;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_par... |
Mapping a url path to a server in nginx | How can I map a URI of the formstaging.example.com/siteAto a virtual server located at/var/www/siteA?The main restriction is that I do not want to create a subdomain for siteA. All examples of nginx.conf I've seen so far rely on having a subdomain to do the mapping.Thanks | You may use theroot directivewithin alocationblock, like this:server {
server_name staging.example.com;
root /some/other/location;
location /siteA/ {
root /var/www/;
}
}Thenhttp://staging.example.com/foo.txtpoints to/some/other/location/foo.txt, whilehttp://staging.example.com/siteA/foo.txtpoint... |
Nginx: allow access only to referrer that match location name | Is there a way, in nginx, to allow access to a "location" only to clients with a referrer that matches the current location name?This is the scenario:http://foooooo.com/bar.org/http://foooooo.com/zeta.net/etc etcI want the contents of the bar.org location available only if the referrer is bar.org. The same goes for zet... | location ~ ^/([a-zA-Z0-9\.\-]*)/(.*) {
if ($http_referer !~ "^$1.*$"){
return 403;
}
} |
How to stop nginx from using port 80 | I'm trying to updatenginxusingsudo apt-get install nginx, but it is giving me an error message related to port 80 being occupied. When I runsudo netstat -tlnp | grep 80I gettcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6845/nginx
tcp 0 0 127.0.0.1:8080 0.0.0.... | I managed to solve the problem by going to127.0.0.1:80in my browser, which brought me to aGitLablogin page. I had forgotten that I had once installed GitLab but wasn't using it. After uninstalling GitLab, port 80 was no longer occupied. |
HTTP/2 behind reverse proxy | So far all the tutorials tell me that I need to enable SSL on my server to have HTTP/2 support.In the given scenario, we have nginx in front of the backend Tomcat/Jetty server(s), and even though performance-wise it worth enabling HTTP/2 on the backend, the requirement to have HTTPS there as well seems to be an overkil... | The typical setup that we recommend is to putHAProxyin front of Jetty, and configure HAProxy to offload TLS and Jetty to speak clear-text HTTP/2.With this setup, you get the benefits of an efficient TLS offloading (done by HAProxy via OpenSSL), and you get the benefits of a complete end-to-end HTTP/2 communication.In p... |
How to pass the remote IP to a proxied service? - Nginx | I'm running a service in localhost at127.0.0.1:8000and I'm proxying this by using:proxy_pass http://127.0.0.1:8000;Problem is that I need to pass the user's IP address to the service.Any ideas? | I send the real IP to django by setting a custom header:proxy_set_header X-Real-IP $remote_addr;Those headers are available inrequest.META |
Docker push nexus private repo fail, 413 Request Entity Too Large | I've deployed an on prem instance of Nexus OSS, that is reached behind a Nginx reverse proxy.On any attempt to push docker images to a repo created on the Nexus registry I'm bumping into a413 Request Entity Too Largein the middle of the push.The nginx.conf file is looking like so:http {
client_max_body_size 0;
... | As it turns out, the linux distro running the containered nginx server was itself running a variation of nginx for any incoming request.Once we set theclient_max_body_sizeto 0 on the nginx configuration file which the OS ran, it worked. |
Nginx proxy_pass directive string interpolation | I'm running Nginx on Kubernetes.When I use the following proxy_pass directive it works as expected:proxy_pass "http://service-1.default";However the following does not work:set $service "service-1";
proxy_pass "http://$service.default";I get an error sayingno resolver defined to resolve service-1.defaultAs far as I can... | I've found the reason and a solution.Nginx detects if a variable is being used inproxy_pass(I don't know how it does that). If there is no variable it resolved the hostname at startup and caches the IP address. If there is a variable it uses a resolver (DNS server) to lookup the IP at runtime.So the solution is to spec... |
nginx configuration for a RESTful API | I am a beginner with nginx and php, so please excuse my basic question.For a RESTful based API (nginx + php) I would need some help with nginx configuration.Here is the relevant snippet of the nginx configuration (as suggestedhere) for redirecting all /api/v1/* requests to my apiv1.php script:server {
server_na... | Replace this:location /api/v1/ {
try_files $uri $uri/ /apiv1.php?$args;
}With the following inside your server block:rewrite ^/api/v1/([^/]+)/([^/]+)/?$ /apiv1.php?class=$1&method=$2? last;Create a php file called apiv1.php and place in the root directory of your web server with the following lines of code:';
echo ... |
Run docker-compose from bash script file | I am new to scripting and require some assistance. I am building docker container using YML file. I have YML code written to automate my web server (docker-compose.yml) and database server(docker-compose-mongo.yml).Now I want to build a bash script that will call for both the yml files and run together.I was wondering ... | You can call them separately:#!/bin/bash
docker-compose -f docker-compose.yml up -d
docker-compose -f docker-compose-mongo.yml up -dOr combine bothnginxandmongoservices in the samedocker-compose.yml. |
How to use Nginx Regexp in the location | The web project have static content into the some /content/img folder.
The url rule is: /img/{some md5}
but location in the folder: /content/img/{The first two digits}/Exampleurl: example.com/img/fe5afe0482195afff9390692a6cc23e1
location: /www/myproject/content/img/fe/fe5afe0482195afff9390692a6cc23e1This nginx lo... | Escaping the braces in the limiting quantifiers is necessary in POSIX BRE patterns, and NGINX does not use that regex flavor. Here, you should not escape the limiting quantifier braces, but you need to tell NGINX that you pass the braces as a part of the regex pattern string.Thus, you need to enclose the whole pattern ... |
How to host a Django project in a subpath? | I am building an API withDjango REST frameworkwhich is served via Gunicorn and Nginx. The project "exampleproject" has to run at a subpath such as:https://100.100.100.100/exampleproject(example IP address). I do not have a domain name registered for the IP.Currently, the start page renders as expected athttps://100.100... | I foundherethat one needs to add the following setting to Django's configuration insettings.py:FORCE_SCRIPT_NAME = '/exampleproject'This seems to rewrite all paths for nested resources. |
Is there a way to get the current time in nginx? | I am trying to inject the time of an nginx server into an HTTP header.I am able to add to an HTTP header, like so:proxy_set_header HELLO-WORLD 'something';But now, I want to be able to inject the time into an HTTP header, something that looks like this:proxy_set_header THE-TIME $time_var;Or something like that.Would th... | You can use variables from SSI modulе: $date_gmt and $date_localproxy_set_header THE-TIME $date_gmt;http://nginx.org/en/docs/http/ngx_http_ssi_module.html#variables |
Timeout when uploading a large file? | I am running a Django app on a Linux platform with gunicorn and Nginx. I allow users to upload a CSV file (approx 2MB) which the app processes and adds to the backend database. The problem is for large files something seems to be timing out after around 2 or 3 minutes and a page entitled 404 Not Found nginx/0.7.6 is di... | I added:proxy_read_timeout 1200;to nginx.conf. This increased the timeout from the default which fixed the problem. I probably don't need to use 1200, it's just the first value I tried. |
nginx location path with proxy_pass | I have following problem, i'm trying to put a Django app with an gunicorn server on my VPS running Nginx. My nginx config looks like this:upstream app_name {
server unix:/path/to/socket/file.sock fail_timeout=10;
}
server {
listen 80 default_server;
listen[::]:80 default_server ipv6only=on;
root /webapps... | You just need a trailing slash for proxy_pass:proxy_pass http://app_name/;it helps you to cut the "appname" prefix so the config looks like:upstream app_name {
server unix:/path/to/socket/file.sock fail_timeout=10;
}
server {
listen 80 default_server;
listen[::]:80 default_server ipv6only=on;
root /webap... |
Running Lua in Nginx config? | So it might just be me that is not super bright or super unlucky when it comes to Google searches, but I can't actually find any way to run Lua in the Nginx config without having to recompile the entire server with LuaJIT.
The thing is that we would like to do tiny edits of some variables without having to recompile ou... | I found a solution myself to this, at least for people using Ubuntu, there is a supported working version of nginx that supports Lua and many other things, you just have to do:apt-get install nginx-extrasInstead of the regular:apt-get install nginxExtras is NOT an add-on package for nginx, it is a fully compiled server... |
Logging the request protocol in nginx? | I was surprised to find that I couldn't find any information on logging the request protocol in an nginx access log. I usually share a server block for both HTTP (80) and HTTPS (443) traffic, and use a combined access log for both. I'd like to indicate in each line in the access log if the request was over HTTP or HTTP... | It's a bit hidden in the docs, but you can use any of the common variables. This includes$scheme. |
Letsencrypt + Docker - the best way to handle symlink? [closed] | Closed. This question needs to be morefocused. It is not currently accepting answers.Want to improve this question?Update the question so it focuses on one problem only byediting this post.Closed2 years ago.Improve this questionI have a Nginx server running onDockeron a Ubuntu host and I wanted to integrateLetsencryptc... | Instead of running let's encrypt on the host, you should do everything inside Docker. And the best is there is already a solution for that:https://hub.docker.com/r/nginxproxy/acme-companionThis enables the proxy to automatically obtain and renew certificates. |
Django with gunicorn and nginx: HTTP 500 not appearing in log files | I have a Django app running on agunicornserver with annginxup front.
I need to diagnose a production failure with anHTTP 500outcome,
but the error log files do not contain the information I would expect.
Thusly:gunicorn hassettingerrorlog = "/somepath/gunicorn-errors.log"nginx hassettingerror_log /somepath/nginx-error... | OK, it took long, but I found it all out:TheServer Error (500)response comes from Django'sdjango.views.defaults.server_error(if no500.htmltemplate exists).TheInternal Server Errorfrom the bonus question
comes from gunicorn'sgunicorn.workers.base.handle_error.nginx logs the 500 error in the access log file, not the erro... |
Does uWSGI need to be restarted when Django code changes? | I'm working on a Django webapp that's running under nginx and uWSGI. When I deploy new Django code (e.g., settings.py), do I need to restart uWSGI? If so, why?Background: I had a scenario where I updated settings.py and some other code and deployed it. I did not see the changes in the webapp behavior until I restart... | Yes, you need to restart the uWSGI process.Python keeps the compiled code in memory so it won't get re-read until the process restarts. The django development server (manage.py runserver) actively monitors files for changes, but that won't happen by default with other servers. If you want to enable automatic reloading... |
How to detect X-Accel-Redirect (Nginx) / X-Sendfile (Apache) support in PHP? | About ApplicationI am working on an e-commerce application in PHP. To keep URL's secure, product download links are kept behind PHP. There is a file, say download.php, which accepts few parameter via GET and verifies them against a database. If all goes well, it serves file using readfile() function in PHP.About Proble... | To detect if the mod_xsendfile apache module installed, you can try this code:if function_exists('apache_get_modules')
&& in_array('mod_xsendfile', apache_get_modules()) {
header("X-Sendfile");
}But this code just check if the module installed only, that can cause errors if it's installed but configured wron... |
Still getting 413 Request Entity Too Large even after client_max_body_size 100M | I'm using Rails and Nginx on Digital ocean and I've been trying to upload a 17.6 MB file and I'm still getting413 Request Entity Too Largeeven after settingclient_max_body_size 100Min my /etc/nginx/nginx.conf file.Here's the snippet from the file:http {
##
# Basic Settings
##
client_max_body_size 100M;
send... | Okay. I figured this out. Following the Digital Ocean guide forhow to configure nginx, I was settingclient_max_body_size 100Min the file/etc/nginx/nginx.conf. And for sure, changing things there definitely had impact on what the server did. Especially when I would mess something up in that file and the server stopped f... |
Django's HttpResponseRedirect is http instead of https | My server runs Django + Gunicorn + nginx.I have added an SSL certificate and configured nginx to redirect http to https. When an https request is received, nginx passes it to Gunicorn as http.My program sometimes returnsHttpResponseRedirect, and the browser gets a redirect response and re-requests as http, so nginx red... | In the nginx configuration (inside thelocationblock), specify this:proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;Theproxy_redirecttells nginx that, if the backend returns an HTTP redirect, it should leave it as is. By default, nginx assumes the backend is stupid and tries to be smart; if the backend re... |
Nginx ingress controller vs HAProxy load balancer | What is the difference between Nginx ingress controller and HAProxy load balancer in kubernetes? | First, let's have a quick overview of what anIngress Controlleris in Kubernetes.Ingress Controller:controller that responds to changes inIngressrules and changes its internal configuration accordinglySo, both the HAProxy ingress controller and the Nginx ingress controller will listen for theseIngressconfiguration chang... |
Docker: how to manage development and production settings? | I'm just getting started with Docker. With the official NGINX image on my OSX development machine (with Docker Machine as the Docker host) I ran up against the bug withsendfileand VirtualBox which means the server fails to show changes I make to files.The workaround for this is to use a modified nginx.conf file that tu... | You could mount your customnginx.confinto the container indevelopmentvia e.g.--volume ./nginx/nginx.conf:/etc/nginx/nginx.confand simply omit this parameter todocker runinproduction.If usingdocker-compose, the two options I would recommend are:Employ the limited support forenvironment variable interpolationand add some... |
how to deploy yeoman angular-fullstack project? | I want to deploy a simple angular projet made with angular fullstack.https://github.com/DaftMonk/generator-angular-fullstackI tried :yo angular-fullstack test
grunt buildThen, in dist I got 2 folders: server and public.how to deploy them on a linux server ?with forever/node and nginx ???
I want to self host my projec... | 1.)Install nginx2.)Proxy forward nginxto your node port. SeeDigital Oceans How-To.nginx.confserver {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
... |
How do I call a local shell script from a web server? | I am running Ubuntu 11 and I would like to setup a simple webserver that responds to an http request by calling a local script with the GET or POST parameters. This script (already written) does some stuff and creates a file. This file should be made available at a URL, and the webserver should then make an http reque... | This tutorial looks good, but it's a bit brief.I have apache installed. If you don't:sudo apt-get install apache2.cd /usr/lib/cgi-bin
# Make a file and let everyone execute it
sudo touch test.sh && chmod a+x test.shThen put the some code in the file. For example:#!/bin/bash
# get today's date
OUTPUT="$(date)"
# You ... |
How to run multiple Django sites on Nginx and uWSGI? | Is it possible to run multiple Django sites on the same server using Nginx and uWSGI?I suppose it's necessary to run multiple uWSGI instances (one for each site). I copied /etc/init.d/uwsgi to uwsgi2 and changed the port number. But, I got the following error:# /etc/init.d/uwsgi2 start
Starting uwsgi: /usr/bin/uwsgi al... | You can create create multiple virtual hosts that allow you to host multiple sites, independent from each other. More info here:http://wiki.nginx.org/VirtualHostExample.A bit more detailed info here as well on how to setup virtual hostshttp://projects.unbit.it/uwsgi/wiki/RunOnNginx#VirtualHosting. |
Server-side auto-minify? | Is there any way to automatically minify static content and then serve it from a cache automatically? Similar to have mod_compress/mod_deflate work? Preferably something I could use in combination with compression (since compression has a more noticeable benefit).My preference is something that works with lighttpd but ... | You can try nginx's third party Strip module:http://wiki.nginx.org/NginxHttpStripModuleAny module you use is just going to remove whitespace. You'll get a better result by using a minifier that understands whatever you're minifying. e.g. Google's Closure javascript compiler.It's smart enough to know what a variable is ... |
How can I properly configure nginx to work with NG Serve and Angular CLI? | I've been trying to research Nginx to configure a proxy with Angular 5 ng serve on localhost:4200, however only come up with results for serving a project that's been built. The configuration I've found from this research "somewhat" works, but results in a white page that isn't loading any data:dev:12 GET http://192.16... | First, check your Angular app'stag - it needs to match the app's new location. So, for example, if you're hosting your app through nginx athttps://localhost/dev/, yourtag will need to be:You can find this tag in your app'sindex.html.Second, nginx won't automatically proxy all the traffic thatng serveuses for live-relo... |
Rails 5 Action Cable deployment with Nginx, Puma & Redis | I am trying to deploy an Action Cable -enabled-application to a VPS using Capistrano. I am using Puma, Nginx, and Redis (for Cable). After a couple hurdles, I was able to get it working in a local developement environment. I'm using the default in-process /cable URL. But, when I try deploying it to the VPS, I keep gett... | Finally, I got it working! I've been trying various things for about a week...The 301-redirects were caused by nginx actually trying to redirect the browser to /cable/ instead of /cable. This is because I had specified /cable/ instead of /cable in thelocationstanza! I got the idea fromthis answer. |
How do I configure nginx as proxy to jetty? | I've been trying to set up nginx as proxy to jetty. I want to do something as explained inthis answerbut for Jetty not ring.I've created a.warand I placed it in~/jetty/jetty-dist/webapps/web_test-0.1.0-SNAPSHOT-standalone.warSay, I want to use the domain example.com with ip address 198.51.100.0.I've also copied/etc/ngi... | How to configure nginx to work with a java server. In the example Jetty is used.Edit/etc/nginx/sites-available/hostname:server {
listen 80;
server_name hostname.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For ... |
Ansible Playbook to run Shell commands | I recently dived into Ansible for one of my servers, and found it really interesting and time saving. I am running an Ubuntu dedicated server and have configured number of web applications written on Python and a few on PHP.
For Python I am using uwsgi as the HTTP gateway. I have written shell scripts to start/restart ... | You don't even need a playbook to do this :Restarting nginx :ansible your_host -m service -a 'name=nginx state=restarted'(seeservice module)Kill a process by process idansible your_host -m command -a 'kill -TERM your_pid'(adjust signal, and use pkill/killall if you need to match a name; seecommand module)However, I wou... |
Missing custom header with django, nginx and gunicorn | Disclaimer:I'm working in a project where exist an "huge" webapp that have an api for mobiles, so change the api is not an option.This application was developed time ago and several developers have worked on it,Having said that, the problem is this;In the api for mobile of this site (just views than returns json data),... | If Django is accessed using uwsgi_pass, then in the appropriate location(s) ...# All request headers should be passed on by default
# Make sure "Token" response header is passed to user
uwsgi_pass_header Token;If Django is accessed using fastcgi_pass, then in the appropriate location(s) ...# All request headers ... |
Proxy a Flask app running on gunicorn to a subpath in nginx | I have a Flask app running with gunicorn onhttp://127.0.0.1:4000:gunicorn -b 127.0.0.1:4000 webapp:appNow I would like to use nginx as a reverse proxy and forwardhttp://myserver.com/webapptohttp://127.0.0.1:4000in a way that everyhttp://myserver.com/webapp/subpathgoes tohttp://127.0.0.1:4000/subpath.The proxy/redirect ... | I solved my problem: The snippethttp://flask.pocoo.org/snippets/35/does work, I was so stupid to have absolute URLs in my templates. I changed that tourl_for()and now it works like charm. |
How do I configure nginx to load try_files from a different folder? | I need some help configuring nginx to load files from a different folder. Here is my config:index index.php;
server {
server_name domain.com;
root /www/domain.com/www/;
location / {
try_files $uri $uri/ /php_www/index.php;
}
location ~ \.php$ {
try_files $uri =404;
... | You can use therootdirective insidelocation. |
Installed gitlab, but only nginx welcome page shows | I installed gitlab using itsinstallation guide. Everything was OK, but when I open localhost:80 in the browser all I see it the messageWelcome to nginx!. I can't find any log file with any errors in it.I am running Ubuntu in VirtualBox. My /etc/nginx/sites-enabled/gitlab config file reads:# GITLAB
# Maintainer: @randx
... | Thenginx documentationsays:Server names are defined using the server_name directive and determine which server block is used for a given request.That means in your case that that you have to enteraridev-VirtualBoxwithin your browser instead of localhost.To get this working you have to enteraridev-VirtualBoxwithin your ... |
How do I set up a Kubernetes Ingress rule with a regex path? | I'd like to use regex in the path of an Ingress rule, but I haven't been able to get it to work.For example:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cafe-ingress
spec:
tls:
- hosts:
- cafe.example.com
secretName: cafe-secret
rules:
- host: cafe.example.com
http:
paths:
... | Apparently this question is still getting traffic, so I feel like I should update it. I'm no longer using the nginx ingress, so I can't verify this works. According tohttps://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/:The ingress controller supportscase insensitiveregular expressions in thespe... |
django with nginx + uwsgi | I am trying django on nginx + uwsgi.
It works very well (faster than apache mod_wsgi), but if I have more than 100 concurrent connexion ( ie : tested with ab -n 100000 -c 150http://localhost:8081/),
I have some broken pipe on uwsgi logs :nginx.conf :user myuser;
worker_processes 8;
events {
worker_connections ... | I found the solution,
The problem is not at uwsgi side, there is a linux limitation : socket are 128 request long, so to enlarge the waiting queue, you have to tune the kernel :ie :echo 3000 > /proc/sys/net/core/netdev_max_backlog
echo 3000 > /proc/sys/net/core/somaxconn |
AWS Elastic Beanstalk - Request Entity Too Large (413) | I am trying to deploy a Node-based web service to elastic beanstalk but running into problems when posting too much data. The issue seems to be at the nginx layer, not the Node / express layer. The message I get is:
413 Request Entity Too Large
413 Request Entity Too Large
nginx/1.6.2
Based on other answers on StackO... | I figured out what the issue was. The .ebextensions folder was hidden in my file system and was not being included in my deployment ZIP when I published to AWS. |
HAProxy and URL Rewriting Configuration | I would like to ask how HAProxy can help in routing requests depending on parts of the URL.To give you an overview of my setup, I have the HAProxy machine and the two backends:IIS website (main site)Wordpress blog on NGINX (a subsite)The use-case:I'm expecting to route requests depending on the URL:www.website.com/lang... | Your regex is wrong, you're assuming the server is in the request path. To match the request paths in the headers use a regex like this one:reqrep ^([^\ ]*)\ /lang/blog/(.*) \1\ /blog/lang/\2you can use reqirep as well but that is only useful if your servers actually serve/BLog/lAnG/as well. |
unicorn nginx upstream server not starting | My unicorn server was running fine, but has stopped working and I can't figure out how to get it restarted.2011/04/18 15:23:42 [error] 11907#0: *4 connect() to unix:/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 71.131.237.122, server: localhost, request: "GET / HTTP/1.... | I had similar issue with nginx and unicorn setup.Every day I've seen in nginx error.log this error:failed (11: Resource temporarily unavailable) while connecting to upstreamThe way I fixed it was to change unix socket to tcp socket.so insteadupstream unicorn_app {
server unix:/tmp/sockets/unicorn.sock fail_timeout=0;... |
s3 proxy on kubernetes using Ingress | I am usingthis ingress controllerand would like to setup a s3 proxy to some bucket. If I call in a browser the urlhttps://my-kube-server.org/img/dog.jpgI expect to see/download the image athttps://s3.eu-central-1.amazonaws.com/mybucket123/pictures/dog.jpgI can setup a rewrite rule and point to an external service as ex... | One of the possible solutions is to start the pods on each cluster node usingDaemonSetthat connect the S3 storage to the local directory usings3fs.S3FS-FUSE:This is a free, open-source FUSE plugin and an easy-to-use utility which supports major Linux distributions & MacOS.
S3FS also takes care of caching files locall... |
CORS doesn't work despite headers set | I have an app where the client makes a multipart request from example.com to api.example.com through https with Nginx, then api uploads the file to Amazon S3.It works on my machine but breaks when other people try it on a different network. Giving me this error:[Error] Origin https://example.com is not allowed by Acces... | The problem turned out to be Nginx not accepting large files. Placing this in the location block of my nginx server config solved my issue:client_max_body_size 10M; |
Using prerender with proxy in nginx | I'm trying to useprerender.ioto get an snapshot of angularjs pages. Currently I have an NodeJS instance for the web app andnginxreverse proxy redirects requests from port80to4000.According to prerender nginx manual (https://gist.github.com/thoop/8165802) I can forward search-engine bot requests to the prerender url but... | I believe that theprerender examplehas the answer. If prerender is set to 1, it uses rewrite and then proxy_pass.So you would change this:if ($prerender = 0) {
rewrite .* /index.html break;
}to this:if ($prerender = 0) {
rewrite .* /index.html break;
proxy_pass http://[INTERNAL IP]:... |
Python: uWSGI configuration for NGINX+FLASK | I successfully managed to install:
NGINX + uWSGI + Flask
on a CentOS 6.x serverbut I still have some doubts in terms of configuration:1) I am running NGINX as a service: service nginx start/stop/restartif I type "ps aux | grep nginx", I can see 2 processes:- (by user root) master process /usr/sbin/nginx -c /etc/nginx/n... | I've moved the most important points from the comments.Yep, that's the normal behavior. Nginx's master process needs root
privileges to manage listening sockets on the machine.Thisforum thread states that youcanchange it, but it may cause
problems. However, Nginx does allow to change the owner of the
worker processes.... |
Does Nginx have separate queuing mechanism for requests? | Consider the following situation: you are deploying application that can serve 1 req./sec. What would happen if I send 10 request in 1 second? I wrote simple app to test that:https://github.com/amezhenin/nginx_slow_upstream.
This test shows that your requests will be served _in_exact_same_order_ they were sent.For now,... | Nginx doesn't have it own queue, instead it pushes all requests to the application server, which have alistensocket:#include
#include
int listen(int sockfd, int backlog);
(http://linux.die.net/man/2/listen)backlogdefines the length of this queue. You can read the full conversationhere. |
asp.net core 2.0 Unable to Post to database | I have a web application that is being developed on a windows env and runs on ubuntu 16.04.I have no issues Posting info to my sqlite database fileblog.db(located in the /. directory of the project ) in my windows environment, however when I try the same action on my ubuntu server, I get the following error:Microsoft.A... | It was my nginx configuration.within /./etc/nginx is a file called: nginx.confI had proxy_set_header Connection "upgrade";when it should be proxy_set_header Connection $http_connection;This fixed my problem and my database now works on the ubuntu side of things. |
Cloud-front backed with Nginx (which proxies to S3) randomly missing already cached items? | I wish to serve images from aS3 bucketwithCloudfrontas CDN frontend, for that I tried the following:What Iwish to acheive(Attempt 2) -- (Misses cloudfront cache randomly)I have the following setup to serve images: (Cloudfront-->Nginx-->S3)<<<<<<<< SampleS3headers >>>>>>>>>><<<<<<<< SampleNginx -> S3headers (AddedCache... | After about4 monthsof repetitive to-n-fro withamazon supportfailed to resolve the issue.All problems still persisting:The cache expires in about a day and misses after24 hours. ( My expiry is 1 year )All headers andaws settingsverified byamazon supportthemselvesUnfortunately, the company is still paying for this awful ... |
how to deflate js file in nginX? | I’m looking for "how to compress load time js file" and I try the solution of myquestion(I’m using Extjs).My friend suggestthistoo. But, it use Apache as web server. Anybody know how to do the trick in NGINX??My hosting uses nginx as web server and i don’t know anything about web server configuration.sorry, if my engli... | If you do not know anything about web server configuration, I am assuming you also do not know how/where to edit the config file.The nginx conf file is located at/etc/nginx/nginx.conf(verified in Ubuntu 12.04)By default, nginx gzip module is enabled. So check from this service whether it is enabled on notusing an onlin... |
REMOTE_ADDR not getting sent to Django using nginx & tornado | So I got a simple setup with nginx for static media and load balancing and tornado as webserver for django (4 servers running). My problem is remote_addr not getting passed on to django so I'm getting a KeyError:article.ip = request.META['REMOTE_ADDR']The remote address is getting sent through as X-Real-IP (HTTP_X_REAL... | Try this one:location / {
proxy_pass http://frontends;
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header REMOTE_ADDR $remote_addr;
}Just addproxy_set_header REMOTE_ADDRa... |
C compiler gcc not found while installing passenger and nginx | I'm trying to install Passenger and Nginx on my VPS.I followedthese instructionsand replaced all links of all sources to the current version.But when i ran the Phusion Passenger installer for Nginx, something with gcc compiler went wrong:Compiling and installing Nginx...
# sh ./configure --prefix='/opt/nginx' --with-ht... | If you do have gcc installed, the problem stems from /tmp being mounted as noexec. The error doesn't exactly help, but if you remount /tmp as exec you can install passenger properly.mount -o remount,rw,exec,nosuid /tmp |
nginx trouble loading index file [closed] | Closed.This question isoff-topic. It is not currently accepting answers.Want to improve this question?Update the questionso it'son-topicfor Stack Overflow.Closed10 years ago.Improve this questionI have this vhost confserver { # php/fastcgi
listen 80;
server_name trinityplex.com www.trinity.com;
error... | Maybe the missing ; after fastcgi_pass? |
Disable SSL redirect for Kubernetes NGINX ingress | An SSL redirect is enabled by default in a Kubernetes NGINX ingress. How can this be disabled? Current implementation below:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: project_name-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- p... | Addingnginx.ingress.kubernetes.io/ssl-redirect: "false"toannotationswill disable the SSL redirect:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: project_name-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- ... |
How to write only logs with 200 status | I'm trying to figure out how to do the following:Request is coming in.HttpLuaModuleperforms some action against the request. If request is valid than Lua will finish processing withngx.exit(202). But there are some conditions that may (and will) occur during the processing andnginxmight return 403 , 404, 503 Errors.Wha... | This is the solution I came up with:auth.lua-- Some logic goes here
-- ....
-- ....
ngx.var.return_status = 200nginx.confhttp {
lua_package_path .....;
lua_package_cpath ....;
rewrite_by_lua_no_postpone on;
server {
set $return_status 1;
location /foo {
rewrite_by_lua_file " ... |
how to get query parameter in lua or nginx? | I am trying to implement this-https://gist.github.com/MendelGusmao/2356310Lua,nginx based URL shortener,The only change i want to implement is when some query string parameter comes with shortened URL i need to take that parameter and insert into the long URL.e.g.http://google.com?test=2will be likehttp://abc.in/abcwhi... | You should be able to usengx.var.arg_namewherenameis the name of the query parameter you want to access. SeeVariables with Infinite Names section in this tutorialfor details on query parameter handling; you may also check myblog postfor Lua nginx/openresty examples.As an alternative, you can usengx.req.get_uri_args()to... |
how to urldecode a request_uri string in Lua | When I usengx.var.request_uriI'm getting back a string that contains %20 in place of spaces. Is there a urldecode() function or similar to decode my string? | The decoded URI can be found inngx.var.uri. It does not contain the query string, if you need it seengx.var.query_string.EDIT: if you cannot use this, here is a simple way to unescape a URL in Lua.local hex_to_char = function(x)
return string.char(tonumber(x, 16))
end
local unescape = function(url)
return url:gsub... |
PHP Startup: Unable to load dynamic library (NEW RELIC) | I am running Ubuntu 12.04 with Nginx and the latest PHP. The story goes like this:
I tried to install the new relic PHP agent per the instructions for ubuntu:wget -O - http://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.newrelic.com/debian/ newrelic non-free"
> /etc/apt /so... | Ok, I found the answer. I can't describe how grateful I am to @mike in the following post:Error In PHP5 ..Unable to load dynamic library. I ran$ grep -Hrv ";" /etc/php5 | grep -i "extension="and it returned a large list of files and one of them was newrelic.ini in/etc/php5/cli/conf.d/which to be honest with you I wasn'... |
Match the path of a URL, minus the filename extension | What would be the best regular expression for this scenario?Given this URL:http://php.net/manual/en/function.preg-match.phpHow should I go about selecting everything between (but not including)http://php.netand.php:/manual/en/function.preg-matchThis is for anNginxconfiguration file. | Like this:if (preg_match('/(?<=net).*(?=\.php)/', $subject, $regs)) {
$result = $regs[0];
}Explanation:"
(?<= # Assert that the regex below can be matched, with the match ending at this position (positive lookbehind)
net # Match the characters “net” literally
)
. # Match any single character t... |
NGINX change config location | I'm working on getting NGINX configured on a server and I've been able to get all of my files into/usr/local/nginx/html/. I've also created annginx.conffile in/usr/local/nginx/conf. All it contains is:server {
root /usr/local/nginx/html;
index index.html index.html;
}I've been using/usr/local/because that's the... | Whether you're starting nginx in a shell or using a daemon service (which is simply a wrapper around the command line api), the answer lies inthe command line API.As you learned, the default location nginx looks in for the configuration file is /etc/nginx/nginx.conf, but you can pass in an arbitrary path with the-cflag... |
nginx 403 Forbidden error | I'm trying to set up graphite to work with grafana in docker based on this project :https://github.com/kamon-io/docker-grafana-graphiteand when I run my dockerfile I get 403 Forbidden error for nginx.my configurations for nginx are almost the same as the project's configurations. I run my dockerfiles on a server and te... | That's because you are hitting the first location block and the index file is not found. |
nginx how to get the request client ipaddress | I have ngnix proxying to a nodejs server. I am trying to read the request client ip address/host name in my nodejs, but it's always::ffff:127.0.0.1But in my nginx access log, I can see the client ip address printed, not sure why my nodejs server can't get it.x.x.x.x - - [24/Aug/2017:14:28:01 -0700] "GET ...." | Add the following to your nginx configuration stanza that proxies to NodeJS:proxy_set_header X-Real-IP $remote_addr;Now you can read the header 'X-Real-IP' in NodeJS |
504 Gateway Time-out uwsgi + nginx django application | I'm trying to run my Django application using Nginx + uwsgi, but I receive504 Gateway Time-outafter one minute of loading.My app takes time to do what needed as it searches for specific things on several websites.My nginx conf is the next one:upstream uwsgi {
server 127.0.0.1:8000;
}
server {
listen 80;
s... | If its an internal task that takes too much time for processing, use celery to run the task.http://docs.celeryproject.org/en/latest/userguide/tasks.htmlIf its not purely an internal task, eg: - uploading a large file, then increase the Nginxclient_body_timeoutto greater than60s.Its because of the default timeout in ngi... |
why do i have error "Address already in use"? | i run my flask app, and it works good, but by the time the app is stopped and in my uwsgi logprobably another instance of uWSGI is running on the same address (127.0.0.1:9002).
bind(): Address already in use [core/socket.c line 764]when i run touch touch_reload, app is working again.
I run anything else on the se... | i have same issue, but the problem was in sqlalchemy, try to add this:@app.teardown_request
def shutdown_session(exception=None):
from extension import db
db.session.remove() |
Get headers with an underscore on NGINX | I have multiple apps in Google Play and App Store. These send custom request headers but these headers include an underscore e.gapi_key.The server has now moved from PHP 5.2 on Apache to PHP 5.5 on nginx. On NGINX,apache_request_headers()andgetallheaders()are not available.Is there any way to read custom request header... | You need to setunderscores_in_headers oninyour NGINX config. |
403 forbidden on wordpress index with nginx, the rest of the pages work fine | I'm setting up my blog on a new EC2 instance because one of the sites on the server that's currently hosting it is being DDoSed.
I'm having some trouble with nginx, because I can either see all the pages fine but 403 on the index, or see the index but 404 on the pages (depending on the config I'm using)Here's my nginx... | Addindex index.php;In the server block, if it doesn't work then you need to remove the$uri/because you don't want to do aautoindex onEDIT: Just noticed that you already figured out your problem, so I'll add the reasoning behind it, the reason why you neededautoindex on;is because without it nginx will follow thetry_fil... |
502 Bad Gateway when using ExpressJS with nginx | If I run my expressjs app like so:coffee server.coffeeand navigate tolocalhost:8080, everything works just fine.However, when I reverse proxy 8080 with nginx with the following configuration:server {
listen 0.0.0.0:80;
server_name localhost;
access_log /var/log/nginx/nodetest.log;
location / {
pr... | Try this patch...-proxy_pass http://node/;
+proxy_pass http://node; |
nginx location tilde | What is the tilde (~) doing in an Nginx Location directive? ie:location ~* \.(png|gif|jpg)$ {
[...configuration]
} | The tilde (~) is an identifier for Nginx letting it know that the location block is using a REGEX to match the location."~" = REGEX match, case-sensitive"~*" = REGEX match, case-insensitiveNginx Docs |
Python bottle vs uwsgi/bottle vs nginx/uwsgi/bottle | I am developing a Python based application (HTTP -- REST or jsonrpc interface) that will be used in a production automated testing environment. This will connect to a Java client that runs all the test scripts. I.e., no need for human access (except for testing the app itself).We hope to deploy this on Raspberry Pi's, ... | Flask vs Bottle comes down to a couple of things for me.How simple is the app. If it isverysimple, then bottle is my choice. If not, then I got with Flask. The fact that bottle is a single file makes it incredibly simple to deploy with by just including the file in our source. But the fact that bottle is a single f... |
Nginx loses POST variable with http -> https redirect | I have a website set up that uses the redirect method...server {
listen 80;
server_name example.org;
return 301 https://$server_name$request_uri;
}However when a page is posted to "http://example.com" it redirects to "https://example.com" and in the process, it strips the POST.I recognize this is how it wor... | If you are willing to forgo the "permanent" redirect status, I believe a 307 redirect instead of a 301 will preserve the POST. There actually is a redirect that is permanent and preserves the post, a 308, but it isn't well adopted yet by browsers and other user agents. |
Serving Large Files Through Nginx via Rails 2.3 Using x-sendfile | Let's say I have a Rails 2.3.2 application fronted by nginx and served by mongrel in which I need to serve a large static file through Rails (to control access to it). I want the Rails app to delegate the transfer of the file to nginx, to avoid blocking the mongrel instance.The available information seems contradictory... | The main idea: all your controller does is to set the nginxx-accel-redirectheader. Once your controller method returns (which will be very fast), nginx will look at the header your Rails app set. If x-accel-redirect is set, then nginx serves the static file.Your controller will look something like:def show
@attachm... |
How do I convert mod_rewrite (QSA option) to Nginx equivalent? | I'm looking to convert the followingmod_rewriterule to theNginx equivalent:RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA]
RewriteRule ^foo/*$ /bar/index.php [L,QSA]So far I have:rewrite ^foo/(.*)$ /bar/index.php?title=$1&$query_string last;
rewrite ^foo/?$ /bar/index.php?$query_string break;The problem is (I... | These rewrite rules made the scripts work:rewrite ^/foo/([^?]*)(?:\?(.*))? /bar/index.php?title=$1&$2;
rewrite ^/foo /bar/index.php; |
disable request buffering in nginx | It seems that nginx buffers requests before passing it to the updstream server,while it is OK for most cases for me it is very bad :)My case is like this:I have nginx as a frontend server to proxy 3 different servers:apache with a typical php appshaveet(a open source comet server) built by me with python and geventa fi... | According toGunicorn, they suggest you use nginx to actually buffer clients and prevent slowloris attacks. So this buffering is likely a good thing. However, I do see an option further down on that link I provided where it talks about removing the proxy buffer, it's not clear if this is within nginx or not, but it look... |
nginx : rewrite rule to remove /index.html from the $request_uri | I've seen a few ways to rewrite the$request_uriand add theindex.htmlto it when that particular file exists in the file system, like so:if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}but i was wondering if the opposite is achievable:i.e. when somebody requestshttp://example.com/index.html,... | I use the following rewrite in the top level server clause:rewrite ^(.*)/index\.html$ $1 permanent;Using this alone works for most URLs, likehttp://example.com/bar/index.html, but it breakshttp://example.com/index.html. To resolve this, I have the following additional rule:location = /index.html {
rewrite ^ / perman... |
Vagrant: config.vm.provision does not allow me to copy a file to etc/nginx/conf.d? | I am working with a Nginx server.
I want to copy a configuration file to /etc/nginx/conf.d with the Vagrantfile.
The command I use is:config.vm.provision "file", source: "./bolt.local.conf", destination: "/etc/nginx/conf.d/bolt.local.conf"The error I receive is:Failed to upload a file to the guest VM via SCP due to a... | As the error message suggest and also from thedocumentation:The file uploads by the file provisioner are done as the SSH or PowerShell user. This is important since these users generally do not have elevated privileges on their own. If you want to upload files to locations that require elevated privileges, we recommend... |
how to handle nginx reverse proxy https to http scheme redirect | I have set up nginx as a reverse proxy on an ubuntu instance that is hosting jenkins, and a few other applications. I'm using nginx to route to the various applications based on a relative path. All traffic from the client to nginx is over https. Behind the firewall, nginx routes everything over http to the configur... | Ok, I was having the same problem and after some more research and couple of trial and error attempts I figured it out.Try adding the header X-Forwarded-Proto as in the following example:server {
server_name example.com;
proxy_set_header Host $host;
# You need this line
proxy_set_header X-Forwarded-Pr... |
Configuring Gunicorn: No application module specified | I'm trying to deploy a django project with NGINX and gunicorn. I keep getting 502 Bad Gateway. I've been working nonstop on this for the past few days and I can't seem to get this deployed. I've gone through 3 tutorials on Digital Ocean, but they aren't correct, obviously.I keep getting 502 bad gateway, or if I try to ... | Assuming you have nginx proxying to port 8001, you want to do this:gunicorn -b 127.0.0.1:8001 your_project_name.wsgi:applicationYou need to run that from your project folder (where the manage.py file is) |
HTTP Strict Transport Security not respected for IP addresses | I set up a cert for an IP address with nginx, and enabled http strict transport security:add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";The directive is in the headerHTTP/1.1 200 OK
Server: nginx
Date: Wed, 17 Sep 2014 22:46:54 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: ... | If I understand you correctly, you direct you browser to IP address (https://xx.xx.xx.xx/) instead of domain name and expect it to obey HSTS rule?ButRFC 6797 Appendix Aexplicitly exclude IP addresses:HSTS Hosts are identifiedonly via domain names-- explicit IP address identification of all forms is excluded. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.