Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Nginx: Return 301 Redirect When 404 Error | What I want to do whenever I get a 404 error on my domain, automatically 301 to the homepage.I have a lot of old blog posts and such that were linked to, but I don't have them on the blog and if anyone happens to click through from another site that they get kicked to the homepage.How can I do this inside nginx?server ... | Here is the final solution that I got to work using webfaction.server {
listen 12440;
root /some/path/here/nginx/html/noahc/;
server_name www.domain.net, domain.net;
port_in_redirect off;
location /{
error_page 404 = @foobar;
}
... |
Wrong credentials in sending mail using sendgrid | This is the code for sending email using sendgrid i have correct api key still the browser displays error asHTTP/1.1 401 Unauthorized Server: nginx Date: Thu, 14 Jul 2016 08:14:32 GMT Content-Type: application/json Content-Length: 88 Connection: keep-alive {"errors":[{"message":"Permission denied, wrong credentials","f... | Looks like you didn't set the environment variable with the api key that you're trying to use with:$apiKey = getenv(...);Please checkdocumentationhere as it looks like you're using the example code.Just for a test you can use:$apiKey = 'add here your api key';replacing the usage of getenv. It should work. Then you can ... |
Rails 3.1, nginx, Passenger directory index forbidden | I'm getting the following error in nginx (with a 403) when I visit .com:[error] 5384#0: *1 directory index of "/u/apps//current/public/" is forbiddenI'm on Ubuntu 10.04 and I can't for the life of me get nginx, Passenger, Rails 3.1, and Capistrano to play nicely.I'm deploying to /u with Capistrano. Everything in /u is... | Alright, I answered my own question. I was missing passenger_ruby and passenger_root configurations in my nginx.conf file. Note that the passenger_ruby path needs to be the wrapper if you're using RVM.passenger_root /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9;
passenger_ruby /usr/local/rvm/wrappers/ruby-... |
Fatal error: Uncaught Error: Call to undefined function bcadd() | After installed "eduTrac SIS" and accessing "dashboard" got this errorUbuntu 16.4, PHP 7.0(php7.0-fpm), Apache2, Nginx,URL gives error 500 and nginx/error.log displays,FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught
Error: Call to undefined function PHPBenchmark\bcadd() in
/var/www/html/eduTrac-SIS... | PHP does not recognize "bcadd()" gives the error.
"bcadd()" function is included in "bcmath" PHP extention.Just installing the relevant bcmath extension would solved the issue.sudo apt-get install php7.0-bcmathPlease note, you should find the correct version of bcmath extension according to your PHP version.
And restar... |
Nginx rate limit and real IP module | I have anNginxserver pool behind a CDN + load balancer setup. CDN caches HTTP "read" requests (GET, HEAD, OPTIONS) and bypasses "write" requests (POST).I'm usingreal_ipmodule to get clients' IPs fromX-FORWARD-FORheader in a configuration like this:set_real_ip_from
set_real_ip_from
...
real_ip_recursive on;
real_ip_he... | No answer so far, so I'm doing it.I verified it myself -real_ipmodule changes the value of the connection origin internally, and for all intents and purposes, everything related to the source of the connection becomes that IP (got fromX-Forward-For,X-Real-IP, etc), including$binary_remote_addrvariable. So, it's safe to... |
Laravel Valet php-fpm already listening on valet sock | I've upgraded valet on my macbook (running catalina) and followed the laravel docs including re-running thevalet installcommand and am seeing unexpected502 Bad Gatewayerrors. I was checking the logs and found[27-Aug-2019 20:39:06] ERROR: Another FPM instance seems to already listen on /Users/myuser/.config/valet/valet.... | After days of screwing around I found an answer on serverfault that suggested deleting the listening sock. So I ranrm ~/.config/valet/valet.sockand immediately the tailed php log showed[08-Sep-2019 16:55:48] NOTICE: fpm is running, pid 10316
[08-Sep-2019 16:55:48] NOTICE: ready to handle connectionsSo I guess that's al... |
How to block a specific user agent in nginx config | How do I block a user agent using nginx.
so far I have something like this:if ($http_user_agent = "Mozilla/5.0 (Linux; Android 4.2.2; SGH-M919 Build/JDQ39) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.169 Mobile Safari/537.22") {
return 403;}this is from a similar thread on this stack overflow.I run nginx as... | in order to block the specific user agent I included this code in the "server" block:if ($http_user_agent = "Mozilla/5.0 (Linux; Android 4.2.2; SGH-M919 Build/JDQ39) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.169 Mobile Safari/537.22"){
return 403;
}and it worked as expected. |
"set" directive is not allowed here | I am trying to follow this example here-https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-confbut getting error-"set" directive is not allowed herewhat am I doing wrong? Note that I am using openresty and invoking nginx as-nginx -p `pwd`/ -c conf/nginx.confThe context of my nginx.conf matches exactly ash... | After months, an answer is coming :)Github configuration file seems wrong.setdirective is used inserver,locationandifblocks.Syntax: set $variable value;Default: —Context:server, location, ifhttp://nginx.org/en/docs/http/ngx_http_rewrite_module.html#setGood luck! |
GeoIP.dat.gz and GeoLiteCity.dat.gz not longer available? Getting 404 trying to load it | Started couple days ago i can't downloadhttp://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gzhttp://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gzdatabases which i use to enablengx_http_geoip_modulemodule.It was free and available all the time but now. Does anybody know anything... | Maxmind no longer supports Geolite legacy, just Geolite2 :https://blog.maxmind.com/2018/01/02/discontinuation-of-the-geolite-legacy-databases/ |
nginx URL rewrite using negative regex? | I'm trying to redirect requests to https in nginx,unlessit is of the form HOST/ANY_STRING_OF_CHARS/END_OF_URI, e.g.:http://host.org/about# no redirecthttp://host.org/users/sign_in# redirects tohttps://host.org/users/sign_inThis apparently works in Apache, but I don't understand how the bang works (ignore if it doesn't ... | Sends a permanent redirect to the client:server {
listen 80;
rewrite ^(/users/\w+)$ https://$host$1 permanent;
...
}for negative match you could use:if ($request_uri !~ "^/users/\w+$")
{
return 301 https://$host$request_uri;
} |
Node.js Requests returning 301 redirects | I'm brand new to node.js, but I wanted to play around with some basic code and make a few requests. At the moment, I'm playing around with the OCW search (http://www.ocwsearch.com/), and I'm trying to make a few basic requests using their sample search request:However, no matter what request I try to make (even if I ju... | The problem is that Node.JS's HTTP Request module isn't following the redirect you are given.See this question for more:How do you follow an HTTP Redirect in Node.js?Basically, you can either look through the headers and handle the redirect yourself, or use one of the handful of modules for this. I've used the "reques... |
nginx k8s ingress - forcing www AND https? | I have a kubernetes setup that looks like this:nginx ingress -> load balancer -> nginx appafter getting an SSL certificate forwww.foo.com, I've installed it in my nginx ingress as a secret, and it works as expected - traffic towww.foo.comgets redirected to thehttpsversion instead, and browsers display a secure connecti... | You need to add the certificate for the domain you want to be redirected:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: foo-https-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
rules:
- host: foo.com
http:
... |
Serve static gzip files using node.js | I don't want to use a library which gzips on the fly, because of the overhead.The website has some dynamic components which is implemented in node.js.I have some static js and css files as well as their gzipped counterparts. I want to serve the gzipped version only to browsers which support it.I considered using the st... | If you want to have best performance for your clients, just use a CDN. It will take care of gzipping for you and a lot of other stuff. If you need help you can useexpress-cdnmodule.If you don't like CDNs for some reasons, your best bet is using nginx. I see it tagged in your question, but you didn't mention anything ab... |
FastCgi vs PHP-FPM using Nginx web server | I am using thistutorialto install nginx, php and mysql on my new web server.The tutorial is using ISPConfig 3 and there is an option to whether use FastCgi or PHP-FPM.I am wondering which is better of the two. In terms of performance and speed, which of the two is the best to use inline with nginx?BTW, I have also memc... | PHP-FPM is much better than the old FastCGI handling of PHP. As of PHP 5.3.3 PHP-FPM is in core and the old FastCGI implementation isn’t available anymore.My answer was just down voted (after being online for quite some time) and I understand why, so here is a list why PHP-FPM is actually better than the old FastCGI im... |
Django returning "CSRF verification failed. Request aborted. " behind Nginx proxy locally | I'm running a simple Django application without any complicated setup (most of the default, Django allauth & Django Rest Framework).The infrastructure for running both locally and remotely is in a docker-compose file:version: "3"
services:
web:
image: web_app
build:
context: .
dockerfile: Dockerf... | Since you're using a proxy that translates https requests into http, you need to configure Django to allow POST requests from a different scheme (since Django 4.0) by adding this tosettings.py:CSRF_TRUSTED_ORIGINS = ["https://yourdomain.com", "https://www.yourdomain.com"]If this does not solve your problem, you can tem... |
How to forward request IP from NGINX to node.js application? | I have NGINX running as reverse proxy which forwards all http and https traffic to my node.js application, which listens to localhost:portHowever the issue I have is that the node.js application sees all incoming requests as coming from ::ffff:127.0.0.1How can I change the NGINX config such that the real IP will be pas... | Express.js official site has thisguide. Instructions:app.set('trust proxy', true)in js.proxy_set_header X-Forwarded-For $remote_addrin nginx.confYou can now read-off the client IP address fromreq.ipproperty |
Laravel: file_put_contents() permission denied — correct storage/framework/cache permissions? | I'm having struggles with editing the Laravel cache, which is located instorage/framework/cache. I've got a job running that saves to a certain cache, but every time the job runs, this error occurs:ERROR: file_put_contents(/var/www/html/---/storage/framework/cache/data/3c/c7/3cc7fd54b5a3cb08ceb0754f58371cec1196159a): f... | I cleared the cache completely usingsudo php artisan cache:clear. Afterwards, the problem never occurred.Opposed to Ismoil's answer: never make the Laravel storage folder777. It poses a security risk. |
How can I use PHP Mail() function within PHP-FPM? On Nginx? | I have searched everywhere for this and Ireallywant to resolve this. In the past I just end up using an SMTP service like SendGrid for PHP and a mailing plugin like SwiftMailer. However I want to use PHP.Basically my setup (I am new to server setup, and this is my personal setup following atutorial)Nginx
Rackspace Clou... | As there is no value forsendmail_fromyou need to set one inphp.ini:sendmail_from = "[email protected]"Or in the headers when you call tomail:mail($to, $subject, $message, 'From:[email protected]');The email address should follow RFC 2822 for example:[email protected]You <[email protected]>Failing that, have you actuall... |
nginx auth_request: access original query parameter | I'm trying to figure out if it is possible to forward a query-parameter from the original URL to theauth_requesthandler/service?Users should be able to add the API-token as a query-parameter like this:https://example.com/api/user?token=237263864823674238476And not viaheaderorcookie. Can I access thetokenparameter someh... | You'll very likely want to pass the url (the uri) to the auth-request endpoint as well. You can do this in one go:location = /api/auth {
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-METHOD $request_method;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_pas... |
Nginx config for single page app with HTML5 App Cache | I'm trying to build a single page app that utilizes HTML5 App Cache, which will cache a whole new version of the app for every distinct URL, thus I must redirect everyone to/and have my app route them afterward (this is the solution used ondevdocs.io).Here's my nginx config. I want all requests to send a file if it exi... | That loop message suggests that /files/whatever/public/index.html doesn't exist, so the try_files in location / doesn't find $uri when it's equal to/index.html, so the try_files always internally redirects those requests to the @ location which does the external redirect.Unless you have a more complicated setup than yo... |
How to configure nginx to show file content instead of downloading it? | I have a directory index configured and every time I click a file it gets downloaded.I want to tell nginx to show the content for text files instead of downloading them.I still want the download to work when I use wget on those text files.How can I do that? | Thanks to Sergey Moiseev's commentthe answer is quite simple.go to your configuration file and add the followingtypes {
text/plain sh;
}this maps the extension.shto mime-typetext/plain |
Apache and Nginx both on port 80 [closed] | As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened,visit the help ... | I'm not quite sure what your hosting company means by their comment but you won't be able to run BOTH Apache and Nginx on port 80. Once one is bound to port 80 the other will be unable to bind to it.Probably the best configuration in your current situation would be to put Nginx on port 80 and Apache on 8000 or similar.... |
Timestamp to ISO 8601 in Lua | How would you convert a timestamp to an ISO 8601 format (such as2009-01-28T21:49:59.000Z) in Lua?I'm specifically trying to do it by using theHttpLuaModulein Nginx. | Tryos.date("!%Y-%m-%dT%TZ")oros.date("!%Y-%m-%dT%TZ",t)ifthas the date in seconds since the epoch. |
How to read UWSGI parameters in python/flask passed from nginx | I set up python/flask/uwsgi+nginx web app and it works fine. I want to use geoip, I set it up on nginx side:location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/qbaka-visit.sock;
...
uwsgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
}But now I do... | uwsgi_paramsets a wsgienvironkey of the given name to the application. You can use this for headers, which follow the CGI convention of using anHTTP_prefix. the equivalent of yourproxy_set_headerwould be:uwsgi_param HTTP_X_GEOIP_COUNTRY $geoip_country_code;note that the header name must be in upper case and with dash... |
Return custom 403 error page with nginx | Im trying to display the error page in /temp/www/error403.html whenever a 403 error occurs.This should be whenever a user tries to access the site via https (ssl) and it's IP is in the blovkips.conf file, but at the moment it still shows nginx's default error page.
I have the same code for my other server (without any ... | I did heaps of googling before coming here but did some more just now, within 5 minutes I had my answer :PSeems I'm not the only person to have this issue:error_page 403 /e403.html;
location = /e403.html {
root html;
allow all;
}http://www.cyberciti.biz/faq/unix-linux-nginx-custom-error-403-page-configuration/S... |
Multiple HTTP GET requests in one TCP/IP connection - processed parallel or sequential | Me get a lot of Googlebot requests.Googlebot requests up to 11 different files via11 HTTP GET request, all inone single TCP/IPconnection.Are these GET request (all in the same TCP/IP connection) processed via the server inparallelor in sequence?Or is it up the the server?in this case, how doesNginxhandle this? | are these GET request (all in the same
TCP/IP connection) processed via the
server inparallel or in sequence?It is processed in sequence. It is called pipelining. Pipelining is part of HTTP/1.1 and it means that the client need not wait for the current request to
complete before sending the next request over a pers... |
Nginx shows wrong time/timezone | How to fixNginxtimezone? I've configurednginxto serve a directory but datetime of creation is one hour after my real time.I've added to/etc/init.d/nginxexport TZ='Europe/Bratislava'thensudo service nginx reload
sudo service nginx restartBut it didn't help, there should be 14:19 instead of 13:19.EDITTried to changeUbunt... | By default, nginx outputs the directory index in UTC time. If you want it to display the time in your local timezone, you should set theautoindex_localtimedirective to on.autoindex_localtime on |
nginx rewrite virtual directory to file | This should be really easy to do but I'm hitting my head on the wall. If I get a request for www.mysite.com/mypath I want to serve the content of www.mysite.com/myotherpath/thisfile.html. How can I do this with an nginx config. | Use rewrite directive within proper location block. So for example you have basic location which will handle all requestslocation / {
/*your rules here*/
}You will need to add another block, which will do for you handling of specific pathlocation /mypath {
rewrite ^/mypath$ /real/path/to/file/thisfile.html;
}A... |
How to configure nginx to work with Jetty6 webserver? | It seems that nginx is used with php, ruby and python.Anyone has an example of how to setup nginx to work with jetty/tomcat in backend?Thanks. | nginx can forward via HTTP protocol, so just point it to the correct port and you're set:server {
location /anything {
proxy_pass http://localhost:8080/whatever;
}
} |
NGINX configuration for Rails 5 ActionCable with puma | I am using Jelastic for my development environment (not yet in production).
My application is running with Unicorn but I discovered websockets with ActionCable and integrated it in my application.Everything is working fine in local, but when deploying to my Jelastic environment (with the default NGINX/Unicorn configura... | Ok so I finally managed to fix my issue. Here are the different steps which allowed to make this work:1.nginx : I don't really know if this is needed but as my application is running with Unicorn, I added this into my nginx confupstream websocket {
server 127.0.0.1:28080;
}
server {
location /cable/ {
proxy_pa... |
How to fix Sinatra redirecting https to http under nginx | I have a Sinatra app running in nginx (using thin as a back-proxy) and I'm usingredirect '/'statements in Sinatra. However, when I access the site under https, those redirects send me tohttp://localhost/rather than tohttps://localhost/as they should.Currently, nginx passes control to thin with this commandproxy_passhtt... | In order for Sinatra to correctly assemble the url used for redirects, it needs to be able to determine whether the request is using ssl, so that the redirect can be made usinghttporhttpsas appropriate.Obviously the actual call to thin isn't using ssl, as this is being handled by the front end web server, and the proxi... |
NGINX, proxy_pass and SPA routing in HTML5 mode | I have NGINX set up as a reverse proxy for a virtual network of docker containers running itself as a container. One of these containers serves an Angular 4 based SPA with client-side routing in HTML5 mode.The application is mapped to location / on NGINX, so thathttp://server/brings you to the SPA home screen.server {
... | The solution that works for me is to add the directivesproxy_intercept_errorsanderror_pageto thelocation /in NGINX:server {
listen 80;
...
location / {
proxy_pass http://spa-server/;
proxy_intercept_errors on;
error_page 404 = /index.html;
}
location /other/ {
prox... |
Why is my Nginx reverse proxy doing a 301 redirect instead of proxying? | I have an Nginx reverse proxy inside a docker container, which listens to port 3000 and is exposed to 3002:docker run -p "3002:3000" ....The idea is that this reverse proxy will proxy/my-appto the instance running in my laptop on port 8080; and/my-app/apito the cloud instance, inhttps://my-domain.Here's the configurati... | The problem was myHostheader in the cloud upstream, I hadproxy_set_header Host $http_host;But it needed to beproxy_set_header Host my-domain.com; |
Edit a header value in nginx | BackgroundSo I've got a server running a tomcat application hidden behind an Apache proxy. The proxy provides a more user friendly url as well as SSL encryption with automatic redirects so that the app is only accessible on https.I'm busy migrating this to an nginx proxy.One of the issues I've had is that upon login, m... | You can use themapdirective to rewrite your header:map $upstream_http_locationafterlogon $new_location {
~regexp new_value;
}
proxy_hide_header LocationAfterLogon;
add_header LocationAfterLogon $new_location;See the documentation:http://nginx.org/en/docs/http/ngx_http_map_module.html |
Is uwsgi protocol faster than http protocol? | I am experimenting with various setups for deploying django apps.
My first choice was using a simple apache server with mod_wsgi, which I had implemented before for private use.
Since the current deployment is for public use, I am looking at various options.
Based on the information available online, it seems it is go... | Ultimately your bottlenecks are not going to be in the particular routing mechanisms for requests unless you really muck up the configuration. So arguably a waste of time to be focused too much on basing decisions on things at that level.Go watch my talk from PyCon for some context on where bottlenecks are really going... |
Subdomains, Nginx-proxy and Docker-compose | I'm looking for a way to configure Nginx to access hosted services through a subdomain of my server. Those services and Nginx are instantiated with Docker-compose.In short, when typingjenkins.192.168.1.2, I should access to Jenkins hosted on192.168.1.2redirected with Nginx proxy.A quick look of what I currently have. I... | Unfortunately nginx doesn't support sub-domains on IP addresses like that.You would either have to modify the clients hosts file (which you said you didn't want to do)...Oryou can just set your nginx to redirect like so:location /jenkins {
proxy_pass http://jenkins:8080;
...
}
location /other-container {
p... |
node.js app with nginx 502 bad gateway error | i am configuring my node.js app with nginx. It is working fine for http but it is not working for https. When i try to access secure domain. i get this error.502 Bad Gateway
nginx/1.4.6 (Ubuntu)Here is my nginx conf fileupstream node_app_dev {
server 127.0.0.1:3000;
}
upstream node_app_production {
... | Replaceproxy_pass https://node_app_production;withproxy_pass http://node_app_production;Restart the nginx and you should be all set.
Seenginx proxy pass Node, SSL? |
Shiny Websocket Error | I'm new to front end web app development. I'm receiving a WebSocket connection failure as follows:WebSocket connection to 'ws://127.0.0.1:7983/websocket/' failed: Error in connection establishment: net::ERR_EMPTY_RESPONSEI looked up this WebSocket error and found diverted to the following pages.Shiny & RStudio Server: ... | After struggling on this same issue for some days I found that the problem was that the Firewall was preventing the websocket from working. I had Pandas Antivirus installed and Firewall was enabled in it. When I turned it off and used Windows firewall and opened that incoming port then it started working.Hope it helps |
How many nginx buffers is too many? | Reading the nginx documentation, theproxy_buffercommand has this explanatory message:This directive sets the number and the size of buffers, into which
will be read the answer, obtained from the proxied server. By default,
the size of one buffer is equal to the size of page. Depending on
platform this is either 4... | nginx is built to be efficient with memory and its default configurations are also light on memory usage. Nothing will go wrong if you add more buffers, but nginx will consume more RAM.Eight buffers was probably chosen as the smallest effective count that was a square of two. Four would be too few, and 16 would be grea... |
PHP getallheaders alternative | I am trying to switch from apache to nginx on my server. The only problem here is the getallheaders() function I used in my PHP scripts which does not work with Nginx. I have tried the user contributed notes on php site on getallheaders finction but that does not return all request headers.Please tell me how to solve t... | You can still use it but you will have to re-define/re-write it like herehttp://www.php.net/manual/en/function.getallheaders.php#84262 |
Getting Nginx to serve static files from several sources | I have a Nginx config that works fine and serves static files properly:location /static/ {
alias /tmp/static/;
expires 30d;
access_log off;
}But what I want to do now is that if the static file doesn't exist in/tmp/static, Nginx looks for the file in/srv/www/site/static. I am not sure how to achieve that, I... | You can set your root to the common prefix of the two paths you want to use (in this case, it's /), then just specify the rest of the paths in the try_files args:location /static/ {
root /;
try_files /tmp$uri /srv/www/site$uri =404;
expires 30d;
access_log off;
}It may seem disconcerting to use root / in a loca... |
Minimum server requirements for a django project [closed] | Closed. This question isopinion-based. It is not currently accepting answers.Want to improve this question?Update the question so it can be answered with facts and citations byediting this post.Closed9 years ago.Improve this questionI want to deploy a django project with the following stack: Django with Nginx, Gunicorn... | Is a Linode 1GB enoughWell, it'll all run on that. You don't say what sort of load you want to support though.So - here's what you want to do.Add some basic monitoring into the mix - mem/cpu/disk/network traces + record them.Script your server so you can go from an empty vm to working system automatically. There's all ... |
How to run authentication on a mlFlow server? | As I am logging my entire models and params into mlflow I thought it will be a good idea to have it protected under a user name and password.I use the following code to run the mlflow servermlflow server --host 0.0.0.0 --port 11111works perfect,in mybrowser i typemyip:11111and i see everything (which eventually is the... | the problem here is that bothmlflowandnginxare trying to run on thesame port...first lets deal with nginx:1.1 in /etc/nginx/sites-enable make a new filesudo nano mlflowand delete the exist default.1.2 in mlflow file:server {
listen YOUR_PORT;
server_name YOUR_IP_OR_DOMAIN;
auth_basic “Administrato... |
docker run, docker exec and logs | If I do :docker run --name nginx -d nginx:alpine /bin/sh -c 'echo "Hello stdout" > /dev/stdout'I can see "Hello stdout" when I do :docker logs nginxBut when the container is running (docker run --name nginx -d nginx:alpine) and I do :docker exec nginx /bin/sh -c 'echo "Hello stdout" > /dev/stdout'or when I attach the c... | When youdocker execyou can see you have several process/ # ps -ef
PID USER TIME COMMAND
1 root 0:00 nginx: master process nginx -g daemon off;
6 nginx 0:00 nginx: worker process
7 root 0:00 /bin/sh
17 root 0:00 ps -ef
/ #and in Linux, each process has its own stdin, stdout,... |
docker nginx connection refused while connecting to upstream | I use shiny server to build a web-app on port 3838, when i use nginx in my server it works well. But when I stop nginx on my server and try to use docker nginx, I find the site comes to a '502-Bad Gate Way' error and nginx log shows:2016/04/28 18:51:15 [error] 8#8: *1 connect() failed (111: Connection refused) while co... | You have to define upstream directly. Currently your nginx can not proxy to your web application.http://nginx.org/en/docs/http/ngx_http_upstream_module.htmlupstream backend {
server backend1.example.com weight=5;
server backend2.example.com:8080;
server unix:/tmp/backend3;
server backup1.example.... |
How to exclude specific subdomains server_name in nginx configuration | I'm using wildcard inserver_name. I want to redirect all subdomains ofexample.com(configured as *.example.com) tofoo.comexceptxyz.example.comI have configuration as followsserver {
listen 80;
server_name *.example.com;
location / {
proxy_pass http://$1.foo.com;
... | You need at least two server blocks, andnginxwill select the more specific server block to handle the request. Seethis documentfor details.You will need a server block forxyz.example.comsuch as:server {
listen 80;
server_name xyz.example.com;
location / {
proxy_pass http://$1.foo.com;
}
}T... |
if conditions break try_files in nginx configuration | I have a simplelocationblock in my nginx config which matches static files for my website. What I want to do, is to check if the file exists usingtry_files, and if it doesn't, redirect to a URL (in this case specified in the@cdnlocation block). I also want to set some CORS headers.Below is the relevant configuration.lo... | http://agentzh.blogspot.co.uk/2011/03/how-nginx-location-if-works.htmlmight be of interest to you in understanding howifworks. In your case, when theifcondition matches, the request is now being served within theifcontext, andtry_filesis not inherited by that context. Or ashttps://www.digitalocean.com/community/tutoria... |
Nginx's "reuseport" for same IP:PORT pair on different virtual hosts | I'm right understand that it's wrong to use "reuseport" for same IP:PORT pair on different virtual hosts:http {
server {
listen 192.168.0.1:80 reuseport;
server_name server1;
…
}
server {
listen 192.168.0.1:80 reuseport;
server_name server2;... | Answer to your last question - in nginx, thelistendirective is only allowed in theservercontext (that means per virtual host).According tomanual:Thelistendirective can have several additional parametersspecific
to socket-related system calls. These parameters can be specified in
anylistendirective, but only once fo... |
Symfony 2: 404 Not Found Error when tryes to open /app_dev.php | I am getting this error message when try to open/app_dev.phpAn error occurred while loading the web debug toolbar (404: Not Found).
Do you want to open the profiler?When I click ok, I am getting then the error:app_dev.php/_profiler/5053258a822e1and404 Not foundI am using nginxThank you very much for your help.EDIT: He... | I know this isn't exactly what you asked but might help future people who search for this issue, like @yvoyer suggested, my issue was the trailing slash too, my server used nginx and fpm, and in nginx // does not euqal /, so i had to do a bit of fixes on my virtual host conf and it worked fine after that. I'll just pas... |
In nginx, what is the relationship between worker_connections, keepalive_timeout and $connection | The nginx documentation saysmax_clients = worker_processes * worker_connectionsbut how does the keepalive factor into this? I have my configuration setup with 2 worker_processes and 8192 worker_connections; that means I can theoretically handle a maximum of 16384 concurrent connections. Pushing out 16384 streams of dat... | $connection is a counter, not the total number of used connections right now. So it's intended to grow.Keepalive connections cannot be discarded, so the room is worker_processes * worker_connections - keepalive connections |
Nginx Reverse Proxying to Node.js with Rewrite | I have several apps running behind an Nginx reverse proxy, one of which is a Node server with Express.js. I'm proxyingdomain.com/demo/app/tolocalhost:7003/using this Nginx config:http {
...
server {
listen 80;
server_name domain.com;
...
location /demo/app {
pro... | I have made nginx serve static files without even passing those requests to node by adding location directive to the app's nginx configuration file (which is included in nginx.conf):location ~ /(img|js)/ {
rewrite ^(.*)$ /public/$1 break;
}
location / {
proxy_pass http://localhost:3000/;
...
}In case reque... |
Can't run the Nginx executable file | I've installed Nginx web server on my machine under Windows 7 with php.When I start the "nginx.exe", the command prompt opens for a second and then closes automatically, so I can't control it through the command prompt. Couldn't find a solution anywhere.What I want is to open the "nginx.exe" and use various commands th... | First you need to know the path to your nginx.exe file.Once you have that right click on your desktop and click on the new text document.Then type or paste in the following text:c:\
cd c:\nginx
start nginx.exe
cmd /kNow save the file with whatever name you want to use but add the .bat extension to it. Example nginx.ba... |
How to deploy an angularjs application frontend with Nginx and dropwizard | I'm developing an application using angularjs application frontend having as backend dropwizard. I'm planning to use Nginx as gateway for the backend dropwizard server and as an asset server (images and maybe the angularjs application).My question is what is the best strategy for deployement:Bundling angularjs with the... | Following thisanswerYou can use this nginx configuration file in order to proxy the Dropwizard application inside your server from port 8080 to port 80:server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_h... |
Access-Control-Allow-Origin missing on the first response | I'm working on a web application (Angular + Rails) that server assets through CloudFront CDN. The application is served though nginx that's correctly set up to set "Access-Control-Allow-Origin" header. CloudFront is set up to forward the header.Problem is that the header is missing on the first response for an Angular ... | "Access-Control-Allow-Origin" is a response header, not a request header. It is returned by a HTTP server when a HTTP client sends a request with an OPTION method. For example, the ajax API in browsers sends an OPTION request before trying a POST request when the targeted URL is not the current page URL (see Cross Orig... |
HTTP2 support in MAMP Pro | Is there any way to enable HTTP2 support in MAMP Pro? I want to test and improve some of my local development websites with HTTP2 support.I've been searching for a while now, but haven't found a single solution. | Recently I configured HTTP2 for NodeJS APP on MAMP Pro with NGINX. I wrote short article about ithttps://www.linkedin.com/pulse/nodejs-http2-server-mamp-pro-nginx-sergei-iastrebov/I think it'll help you. |
How to prevent "304 Not Modified" in nginx? | I'm trying to disable all the caches in nginx for testing purpose.I've set the following lineadd_header Cache-Control no-cache;I see that the page itself is not cached, but the images, css, and javascripts are. I suspect that this is because Firefox is getting "304 Not Modified" header.Is there a way to prevent it?P.S:... | Sounds right to me.If the agent (in this case Firefox) says 200 OK, it means the transfer happened. |
NGINX open() failed (20: Not a directory) hls vod with secure link module | I have a problem with nginx config for hls streaming. I usekaltura nginx vod moduleand try to addngx_http_secure_link_moduleto protect the stream. The strange thing is I have 404 error if I enablengx_http_secure_link_module(logs below). I think that is because it can't find a file with index.m3u8 on the end, but if I c... | Just moved out this block to server directory and addedvod hls;inside.location ~ \.m3u8$ {
include cors.conf;
vod hls;
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 403; }
} |
RabbitMQ Management Over HTTPS and Nginx | I'm trying to access the RabbitMQ interface over HTTPS/SSL with nginx, and I can't figure out what I'm missing.Here's my rabbitmq.conf file:[
{ssl, [{versions, ['tlsv1.2', 'tlsv1.1']}]},
{rabbit, [
{reverse_dns_lookups, true},
{hipe_compile, true},
{tcp_listeners, [5672]},
{ssl_listeners, [5... | I ended up reverting back to the default rabbitmq.config file, then modified my nginx config block to the below, based on another stackoverflow answer that I can't find right now.location ~* /rabbitmq/api/(.*?)/(.*) {
proxy_pass http://127.0.0.1:15672/api/$1/%2F/$2?$query_string;
proxy_buffering ... |
How Can I run PM2 with Angular-Cli? - Angular2 | How can I run:ng serve --prodwith pm2?ng serve from angular-cli, Angular2. I'm running on DigitalOcean.I have tried to test withhttp-server -p 4200 -d falsein the dist/ folder afterng build --prodWhen I request from the domainhttps://www.unibookkh.com/, i got 404 error: (I've already setup nginx to listen to port 4200.... | This command would work as expected:after I runng build --prodthen run the following command in the dist/ folderpm2 start /usr/bin/http-server -- -p 8080 -d falseUpdateI have found a better solution:which ngthen it will print /usr/bin/ng
then type thispm2 start /usr/bin/ng -- serve --prod |
Could not start uwsgi process | Could not start uwsgi process via ini flaguwsgi --ini file.iniNot any uwsgi pidsps aux | grep uwsgi
root 31605 0.0 0.3 5732 768 pts/0 S+ 06:46 0:00 grep uwsgifile.ini[uwsgi]
chdir =/var/www/lvpp/site
wsgi-file =/var/www/lvpp/lvpp.wsgi
master = true
processes = 1
chmod-socket=664
socket = /var/www... | The key is:error removing unix socket, unlink(): Permission denied [core/socket.c line 198]You (very probably) previously run a uwsgi instance as root creating the unix socket file with root permissions.Now your instance (running instead as www) is not able to re-bind() that socket as it is not able to unlink it (no p... |
How to set correct content-type for apple-app-site-association file on Nginx/Rails | In order to set up universal links for an iOS app, I have created an apple-app-site-association file, and placed it in the /public directory of my Rails app.I can curl it at the correct address, but it returns the wrong content type. Instead ofapplication/jsonorapplication/pkcs7-mimeit returnsapplication/octet-stream, ... | It turns out the nginx configuration file described two servers, and I was adding the location snippet to the wrong one.When I added it to the correct one and reloaded nginx, the file was returned with the expected content-type:HTTP/1.1 200 OK
Server: nginx/1.10.1
Content-Type: application/pkcs7-mime
Content-Length: 24... |
ERROR (no such process) Nginx+Gunicorn+Supervisord | if I run command (to start the app) via supervisor:sudo supervisorctl start myappit is throwing the error of:myapp: ERROR (no such process)I created a file called myappsettings.conf:[program:myapp]
command = /usr/local/bin/gunicorn -c /home/ubuntu/virtualenv/gunicorn_config.py myapp.wsgi
user = ubuntu
stdout_logfile = ... | Try:supervisorctl reread
supervisorctl reloadThat should start the service. I did this as root under Ubuntu 13.04.EDIT:I've had trouble since I posted this with SIGHUP'ing Supervisor processes. I would just like to share a little snippet I found elsewhere:sudo kill -HUP `sudo supervisorctl status | grep $APP_NAME | sed... |
difference between uwsgi module in nginx and uwsgi server | I'm new to linux development. I'm a bit confused on the documentation i read.
My ultimate goal is to host a simple python backed web service that would examine an incoming payload, and forward it to other server. This should be less than 30 lines of code in python.I'm planning to use nginx to serve up python file. From... | You're mixing up things, so let me clarify.Python's standard way of publishing applications via web servers isWSGI--you can think of it as a Python's native CGI.uWSGIis a WSGI-compliant server that usesuwsgiprotocol to talk to other uWSGI instances or upstream servers. Usually the upstream server isnginxwithHttpUwsgiMo... |
How to disable http2 in nginx | due tothisSafari Issue with HTTP/2 and Form POSTS I wanted to disable serving one Webpage via HTTP/2. So I just removed the "http2" from the server_name directive in corresponding nginx server block.server {
listen x.x.x.x:443 ssl;
server_name xxxx;
[...]
}But after I restarted NginX and opened the website in var... | Someone answered with the correct solution here, but the post disappeared...You have to disable http2 for all server blocks on one IP Adress / Port. If there is one server block configured to enable http2 it is enabled for all server blocks on this IP. |
Which web servers support HTTP/2 | I have installed SPDY Indicator chrome extension. It is detecting some sites as SPDY enabled and some as HTTP/2 enabled.Which are the web servers that currently support HTTP/2? I know nginx support SPDY, but does it support HTTP/2? If it does, how can I enable it?UpdateThanks to GolezTrol.The answer is no.Yes as of Sep... | There's a full list of web servers etc that support HTTP/2 athttps://github.com/http2/http2-spec/wiki/ImplementationsHTH |
How nginx process =404 fallback in try_files | I have a example web server with only one index.html file in a www directory. I can setup a nginx with following configuration:location /subfolder {
alias /data/www;
try_files $uri $uri/ /index.html;
}In browser I can see correct response on my local domaintest.local/subfolder, alsotest.local/subfolder/someth... | Thetry_filesdirective only supports these syntaxes:try_files file ... uri;
try_files file ... =code;It doesn't support:try_files file ... uri =code;The difference betweenfileandurihere, is that forfilearguments, NGINX will check theirexistencebefore moving on to next argument; foruri, it won't.If the last argument has ... |
502 Bad Gateway for Laravel 5.4 with nginx and php7.0-fpm in Ubuntu | I have myLaravel 5.4app setup inUbuntu 16.04server withnginxandphp7.0-fpm, it gives502 Bad GatewayNginx virtualhost config,server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/laravel/public;
index index.... | Updating one line with default php based config worked,server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/laravel/public;
index index.html index.htm index.php;
# Make site acces... |
nginx proxy: connect() to ip:80 failed (99: Cannot assign requested address) | An nginx/1.0.12 running as a proxy on Debian 6.0.1 starts throwing the following error after running for a short time:connect() to upstreamip:80 failed (99: Cannot assign requested address)
while connecting to upstream, client: xxx.xxx.xxx.xxx, server: localhost,
request: "GET / HTTP/1.1", upstream: "http://upstreami... | Seems like I just found the solution to my own question: Allocating more outgoing ports viaecho "10240 65535" > /proc/sys/net/ipv4/ip_local_port_rangesolved the problem. |
nginx: why multiple conf files? | There are multiple nginx conf files on single installation. Here is what I found:/opt/nginx/conf/nginx.conf/etc/nginx/nginx.conf/etc/nginx/sites-available/defaultmore in /etc/nginx/conf.dmore in /etc/nginx/sites-availableWhat's the use of those multiple conf files? What is going to happen if there are conflict? Which o... | Start with/etc/nginx/nginx.conf, all of the other files areincludedinto it. Seethis documentfor details.Usenginx -Tto see the complete configuration asnginxsees it. |
Unable to use -lt when running Nginx Docker or cat logs | I've recently pulled a nginx image:docker pull nginxI can run it successfully and go tohttp://server_nameand see the "Welcome to Nginx" page:docker run -d -p 80:80 nginxBut then when I try to check logs:docker exec 6c79549e3eb4f6e5fc06f049b67814ac4560ce2cdd7cc6ae84b44b5ae09a9a05 cat /var/log/nginx/access.logIt just han... | If you go inside the containerdocker exec -it /bin/bashand check the log locationls -la /var/log/nginx/, you will see the following output:lrwxrwxrwx 1 root root 11 Apr 30 23:05 access.log -> /dev/stdout
lrwxrwxrwx 1 root root 11 Apr 30 23:05 error.log -> /dev/stderrClearly, the logs are written in stdout. You can... |
Do these .env GET requests from localhost indicate an attack? [closed] | Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ... | Requests to/.envare, by all means, malicious.Many apps (Laravel based for example) use.envfiles to keep very sensitive data like database passwords. Hackers/their automation scripts attempt to check if.envis public accessible.If they can red.envfiles in the first place, this indicates an improperly configured server an... |
Kubernetes whitelist-source-range blocks instead of whitelist IP | Running Kubernetes on GKEInstalled Nginx controller with latest stable release by using helm.Everythings works well, except adding the whitelist-source-range annotation results in that I'm completely locked out from my service.Ingress configapiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: staging-ingress
... | Yes. However, I figured out by myself. Your service has to be enabledexternalTrafficPolicy: Local. That means that the actual client IP should be used instead of the internal cluster IP.To accomplish this runkubectl patch svc nginx-ingress-controller -p '{"spec":{"externalTrafficPolicy":"Local"}}' |
How to create a Docker container of an AngularJS app? | I have an AngularJS app that has this structure:app/
----- controllers/
---------- mainController.js
---------- otherController.js
----- directives/
---------- mainDirective.js
---------- otherDirective.js
----- services/
---------- userService.js
---------- itemService.js
----- js/
---------- bootstrap.js
---------- j... | First of all, follow thisbest practice guideto build your angular app structure. The index.html should be placed in the root folder. I am not sure if the following steps will work, if it's not there.To use a nginx, you can follow this small tutorial:Dockerized Angular app with nginx1.Create a Dockerfile in the root fol... |
Express and nginx net::ERR_CONTENT_LENGTH_MISMATCH | I'm developing an Express-driven site, that is going through an nginx proxy. Sometimes when loading a page in the browser, I get this:GET http://myapp.local/css/bootstrap.css net::ERR_CONTENT_LENGTH_MISMATCHIf I refresh the page, it usually goes away. But if refresh over and over and over, it will come up again.What is... | Thenet::ERR_CONTENT_LENGTH_MISMATCHis a caching issue. You're telling Nginx to bypass the cache if certain conditions are met (in your case$http_upgrade).You should've specified the caching location for nginx in a configuration file somewhere. A quick fix will be to delete the contents of this folder, restart nginx, an... |
SSL on Nginx throws error (SSL: error:0908F066:PEM routines:get_header_and_data:bad end line) | I generated my SSL from SSLforFree/ZeroSSL, and according to the steps for installation listed on their website,https://zerossl.com/help/installation/nginx/Downloaded the SSL FilesMoved them to the ServerMerged the certificate.crt & ca_bundle.crt with (cat certificate.crt ca_bundle.crt >> certificate.crt)Added followin... | Merging files withcat certificate.crt ca_bundle.crt >> certificate.crt, merges the file without adding any next line character in it.
After merging the files, open the newly created file, i.e, certificate.crt, and you'll see the file structure as follows:-----BEGIN CERTIFICATE-----certificate-1-text-----END CERTIFICATE... |
Get client IP address of a request instead of Cloudflare's IP address | Cloudflare changes the IP addresses of incomming requests because Cloudflare is a middleware between my website and the Internet, a proxy.How should Iget the initial IP address of the request, not Cloudflare its IP address. I heard about themod_cloudflarebut does this plugin only updates the IP address in my logs (?) A... | Cloudflare sets theCF-Connecting-IPand theX-Forwarded-Forheaderson every requestYou can simply get the IP from their special header:let ip = req.headers['cf-connecting-ip']If you expect requests outside of Cloudflare, you can get these IPs the following way:let otherIp = req.headers['x-forwarded-for'] || req.connection... |
NGINX, Disable cache in specific folder for a specific file type | I have -unfortunately Windows- Nginx server that I use for a static content (like product photos and so on). Currently I have had a global setting for caching, but now I need to change it little.I have a folder which path looks something like this:E:\xampp\srv\project-files\projectX\files\users\user-hash\visualisator\v... | location ~ .*files/projectX/files/users/.*jpg$ {
expires -1;
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}This does the trick. |
nginx location with and without trailing slash | I would like to create a location which catches bothhttp://example.comandhttp://example.com/and another location which catches everything else. The first one will serve static html and the other one is for the api and other stuff. I've tried with this:location ~ /?$ {
root /var/www/prod/client/www;
}
location ~ /.... | It is actually much simpler:location = / {
# Exact domain match, with or without slash
}
location / {
# Everything except exact domain match
}Becauselocation = /is more specific, it is always preferred if only the domain name is called (order of the location blocks does not matter).You need regex in Nginx much les... |
nginx unknown directive health_check | I am new to nginx. I am using -health_check uri=/some/uribut on running the test with this command -sudo /usr/sbin/nginx -t -c /etc/nginx/nginx.confI get the following error -nginx: [emerg] unknown directive "health_check" in /etc/nginx/sites-enabled/abc.conf:121Can someone tell what is wrong here..? I have used apache... | According to Nginxdocs:This directive is available as part of nginx commercial subscription. |
nginx: [emerg] a duplicate default server | When I try restart nginx and write in console this commandnginx -tI have an error:nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default.save:20
nginx: configuration file /etc/nginx/nginx.conf test failedsites-enabled/defaultserver {
listen 80 default_server;
listen... | If you look at/etc/nginx/sites-enabled/you see two files,default.saveanddefaultjust remove one of themsudo rm -rf /etc/nginx/sites-enabled/default.save |
nginx - serve only images | I'm trying to setup nginx so "static.domain.com" can only serve images. This is what I have come up with, but I know it can be done more efficiently. I want to serve 403.html if someone tries to access any .htm, .php, directory (anything else I'm missing?) files. Of course, with the exception of 403.htm and static.htm ... | Why not move the images up and then deny all?location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires 7d;
}
location / {
deny all;
}there is no syntax for NOT matching a regula... |
Is there a way to configure Nginx to broadcast incoming requests to multiple upstream servers simultaneously? | The following fragment will pick one server at a time. Is there a way to hit them all at once?upstream backend {
server 17.0.0.1:8000;
server 17.0.0.1:8001;
server 17.0.0.1:8002;
server 17.0.0.1:8003;
}
server {
location / {
proxy_pass http://backend;
}
} | Here is a solution usingngx_http_mirror_module(available since nginx 1.13.4):server {
location / {
proxy_pass http://17.0.0.1:8000;
mirror /s1;
mirror /s2;
mirror /s3;
}
location /s1 { internal; proxy_pass http://17.0.0.1:8001$request_uri; }
location /s2 { internal... |
AspNetCore Azure AD Connect Callback URL is http, not https | I have a AspNet Core 2.0 App which authorizes users with Azure AD using the OpenIdConnect API. The callback uris of the Azure App Entry are defined ashttps://localhost:44369/signin-oidcandhttps://domain.tld/signin-oidc. When I deploy my app on localhost with IIS Express everything works fine and I can authenticate user... | I found a linked question with a post that solved this problem. The post instructed the following insertion prior toapp.UseAuthentication();var fordwardedHeaderOptions = new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
};
fordwardedHe... |
How to access MySql hosted with Nginx Ingress+Kubernetes from client | I am new to Kubernetes and Nginx Ingress tools and now i am trying to host MySql service using VHost in Nginx Ingress on AWS. I have created a file something like :apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
spec:
type: NodePort
ports:
- port: 3306
protocol: TCP
selecto... | Kubernetes Ingress as a generic concept does not solve the issue of exposing/routing TCP/UDP services, as stated inhttps://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/exposing-tcp-udp-services.mdyou should use custom configmaps if you want that with ingress. And please mind that it will never use ho... |
simple nginx reverse proxy seems to strip some headers | I am a beginner at nginx. I have a simple webserver on 8080 that I want to pass all traffic to in this rather small environment. My proxy seems to work except that a custom header is not there when it gets to my upstream server. The server block is below. What would I need to add to this to keep my custom header? ... | Your header contains underscore (_). By default, nginx treats headers with an underscore as invalid and drops them.You should enableunderscores_in_headersdirective.Otherwise, consider changing the header name to one without underscores.GH-clientwill be perfectly valid and proxied to your backend server. |
How do I make web service calls within nginx? | What:I want to make requests to a web service from within nginx on each request that goes through nginx and apply some process based on the response I get from the web service.Application:I am using nginx as a reverse proxy and have multiple webservices to which traffic is routed to. I want to add an additional webserv... | One option is to use theauth_requestmodule. It's not designed with your scenario in mind and is not a default Nginx module so you need to build from source to compile it in with ./configure --with-http_auth_request_module.auth_request is used to pre-authenticate Nginx requests via an remote HTTP call. As long as the re... |
how to access a body of POST request using fastcgi C/C++ application | I am using a library fromhttp://fastcgi.com/in C++ application as a backend and nginx web-server as a front-end.Posting files from HTML-form successfully and can see the temporary files on nginx server side. But I can't figure out how to access a body of multipart POST request using fastcgi_stdio. This is my HTML-form.... | You can access thePOSTbody via theFCGI_stdinstream. For example, you can read from it one byte at a time usingFCGI_getchar, which is a short form forFCGI_fgetc(FCGI_stdin). You can read larger chunks of data in a single call usingFCGI_fread. All of this I found looking atthe source. These sources often reference someth... |
Programmatically add nodes to a load balancer like Haproxy? | I'm very sure this problem has been solved, but I can't find any information anywhere about it...How do sysadmins programmatically add a new node to an existing and running load balancer ? Let's say I have a load balancer running and already balancing say my API server between two EC2 instances, and suddenly there's a ... | You have a few questions in there. For the "add nodes to haproxy without restarting it":What I do for a similar problem is prepopulate the config file with server names.. e.g. web01, web02 ... web20 even if I only have 5 web servers at the time. Then in my hosts file I map those to the actual ips of the web servers.T... |
SSL: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode | To enable https on my node js app I have followed thispageAnd included.ebextensions\https-instance.configfile in my app. I sent my csr to Godaddy and downloaded my cert file.When running app on local host I create my https server using the keys like below and app runs finevar options = { cert: fs.readFileSync('e03aae55... | indentation was wrong. Needed to be multiline. i had it as single line when trying to fix it in parser/etc/pki/tls/certs/server.crt:
mode: "000400"
owner: root
group: root
content: |
-----BEGIN CERTIFICATE-----
MIIFSDCCBDCgAwIBAgIJAOA6rlWwXuEJMA0GCSqGSIb3DQEBCwUAMIG0MQswCQYD
VQQGEwJVUz... |
Where should the uwsgi_params file be located and what is its extension? | I am having trouble wrapping my head around how this file works. I seem to see it in every example. See below:server {
listen 80;
server_name sivusto3.fi;
access_log /var/log/customersite3/access_log;
location / {
root /var/www/customersite3;
uwsgi_pass 127.0.0.1:3033;
include uwsgi_params;
}
} | uwsgi_paramsfileis located inside Nginx directory (/etc/nginxon my Linux machine)me:~$ ls /etc/nginx | grep uwsgi
uwsgi_paramsand has no extension. |
Gunicorn worker timeout | I have a Django application running in Gunicorn behind Nginx. Everything works fine, exect for one strange thing: I have a "download" view and a RESTful json API. When call the download view I use urllib2 to access the json API to get information. And excactly when I try to do this http get request to the json api, the... | I had the same issue using Gunicorn, nGinx, Django andRequestsevery time I did:response = requests.get('http://my.url.com/here')the workers would timeoutI solved the problem by switching from Syncronous (sync) workers to Asynchronous (eventlet) workers.if you are launching command line add:-k 'eventlet'if you are using... |
nginx serving Django in a subdirectory through uWSGI | I have already gone through some previous threads:How do I set subdirectory in nginx with Djangohow to deploy django under a suburl behind nginxServing flask app on subdirectory nginx + uwsgiThe basic lesson is that you should only need to configure your site(s-available) to achieve this. I have now tried various permu... | Eventually gave up on trying to do this "neatly".The final solution was just to make a settings variable that I prefixed to the static_url and projects urls.py file. No SCRIPT_NAME or anything complicated on the nginx side. |
Response returned only after kernel.terminate event | My understanding ofkernel.terminateis that it triggersafterthe response has been returned to the client.In my testing tough, this does not appear to be the case. If I put asleep(10)in the function that's called on kernel.terminate. the browser also waits for 10 seconds. The processing seems to be happening before the r... | This issue turned out to be very specific to my setup (Nginx, PHP-FCGI, Symfony).There were a handful of issues in play that caused the issue:Symfony does not include aContent-LengthnorConnection: closeheaderPHP-FCGI does not support thefastcgi_finish_requestfunctionNginx buffers the response from PHP-FCGI because Gzip... |
Has anyone managed to get SPDY to work behind an Amazon ELB? | We've been using nginx compiled with the spdy module for some time now and despite only being draft 2 of the specs are quite pleased with its performance.However we now have the need to horizontally scale and have put our EC2 instances behind an Elastic Load Balancer.Since ELB doesn't support the NPN protocol we have s... | Doing SSL -> SSL doesnt send the whole TCP packets to your webserver.
AWS decypts the packets using the certificate and re-encrypt it. Your backend only receives the modified packets.
The viable option is to change the protocols to TCP but you will neednginx proxy patchfor http headers or to work better.I'm having same... |
Docker compose - share volume Nginx | I just want to test Docker and it seems something is not working as it should. When I have my docker-compose.yml like this:web:
image: nginx:latest
ports:
- "80:80"when in browser I run mydocker.appdomain (sample domain pointed to docker IP) I'm getting default nginx webpage.But when I try to do something like ... | If you are using Docker Machine onWindows, docker has limited access to your Windows filesystem. By default Docker Machine tries to auto-share yourC:\Users(Windows) directory.So the folder.../Dev/docker/nginx-www/nginx/html/must be located somewhere underC:\Usersdirectory in the host.All other paths come from your virt... |
How to run Nginx on multiple ports | I am trying to configure nginx on two ports with the same instance, for example on port 80 and port 81, but no luck so far. Here is an example of what I am trying to do:worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
se... | your config looks okI think the problem is this (correct me if I'm wrong):you have console.local.com listening on port 81,that means you need to access it ashttp://console.local.com:81/when you access it ashttp://console.local.com/(no explicit port so defaults to port 80)
nginx will check, notice that noting is listeni... |
nginx - missing etag when gzip is used | If I setup nginx to use gzip, it removes any etag header.The reasoning behind this is that the same resource cannot be byte-for-byte identical given that gzip has various compression levels.But nginx also removes a weak etag, which just means that the resources are semantically equivalent. This seems like incorrect beh... | You should upgrade to nginx 1.7.3 or higher.Feature: weak entity tags are now preserved on response modifications, and strong ones are changed to weak. |
NGINX TLS termination for PostgreSQL | I’ve been trying to use NGINX as a TLS terminator for my PostgreSQL database but without success.When I try to connect to the database I get the following error:server closed the connection unexpectedly
This probably means the server terminated abnormally before or while processing the request.When I remove thessloptio... | In short: it's not possible because PostgreSQL has its own handshake that precedes the SSL handshake.To avoid this you can simply set PostgreSQL to use SSL at its level, and use Nginx's TCP stream as pass-through (the communication is encrypted end-to-end by PostgreSQL).Source:https://www.postgresql.org/message-id/d053... |
FastCGI and Nginx - Return HTTP Status | I have a custom FastCGI application behind Nginx and I'm struggling to get Nginx to return anything other than a 200 status code.I've tried the following:Setting fast_cgi_intercept_errors on.Returning codes viaApplicationStatusin theEndRequest.Returning Errors on the StdError stream.Sending any of following headers:"St... | nginx discards the"HTTP/1.1 304 Not Modified\r\n".nginx uses (and eats) theStatusheader.If my fastcgi program returns the header"Status: 304\r\n".Then I get this response:HTTP/1.1 304
Server: nginx/1.6.2
Date: Sat, 21 May 2016 10:49:27 GMT
Connection: keep-aliveAs you can see there is noStatus: 304header. It has been e... |
socks5 proxy/tunnel for nginx upstream? | are there any solution/patch that would make nginx work with a socks upstream?something like this:server {
location / {
proxy_pass socks5://ip:port/
}
} | I've recently wrotea moduledoing exactly what you need. You might need something likeHAProxybeforenginxto support TLS tunneling. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.