Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
Nginx location configuration (subfolders)
lets say I've a path like:/var/www/myside/that path contains two folders... let's say/staticand/manageI'd like to configure nginx to have an access to:/staticfolder on/(eg.http://example.org/) this folder has some .html files./managefolder on/manage(eg.http://example.org/manage) in this case this folder contains Slim's...
To access a path like/var/www/mysite/manage/publicwith a URI like/manage, you will need to usealiasrather thanroot. Seethis documentfor details.I am assuming that you need to run PHP from both roots, in which case you will need twolocation ~ \.phpblocks, see example below. If you have no PHP within/var/www/mysite/stati...
Certbot not creating acme-challenge folder
I had working Let's encrypt certificates some months ago (with the old letsencrypt client). The server I am using is nginx.Certbot is creating the .well-known folder, but not the acme-challenge folderNow I tried to create new certificates via~/certbot-auto certonly --webroot -w /var/www/webroot -d domain.com -d www.dom...
The problem was the nginx configuration. I replaced my long configuration files with the simplest config possible:server { listen 80; server_name domain.com www.domain.com git.domain.com; root /var/www/domain/; }Then I was able to issue new certificates.The problem with my long configuration files was (as f...
Certbot /.well-known/acme-challenge
Should I leave the /.well-known/acme-challenge always exposed on the server? Here is my config for the HTTP:server { listen 80; location '/.well-known/acme-challenge' { root /var/www/demo; } location / { if ($scheme = http) { return 301 https://$server_name$request_uri; ...
Acme challenge link only needed for verifying domain to this ip address
nginx as cache proxy not caching anything
I'm trying to cache static content which are basically inside the paths below in virtual server configuration. For some reason files are not being cached. I see several folders and files inside the cache dir but its always something like 20mb no higher no lower. If it were caching images for example would take at least...
Make sure your backend does not returnSet-Cookieheader. If Nginx sees it, it disables caching.If this is your case, the best option is to fix your backend. When fixing the backend is not an option, it's possible to instruct Nginx to ignoreSet-Cookieheaderproxy_ignore_headers "Set-Cookie"; proxy_hide_header "Set-Cookie"...
Meteor WebSocket handshake error 400 with nginx
I managed to deploy meteor on my infrastructure (Webfactions). The application seems to work fine but I get the following error in the browser console when my application starts:WebSocket connection to 'ws://.../websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
WebSockets are fast and you don't have to (and shouldn't) disable them.The real cause of this error is that Webfactions uses nginx, and nginx was improperly configured. Here's how tocorrectly configure nginx to proxy WebSocket requests, by settingproxy_set_header Upgrade $http_upgrade;andproxy_set_header Connection $co...
nginx close upstream connection after request
I need to keep alive my connection between nginx and upstream nodejs.Just compiled and installed nginx 1.2.0my configuration file:upstream backend { ip_hash; server dev:3001; server dev:3002; server dev:3003; server dev:3004; keepalive 128; } server { listen 9000; server_name dev; ...
Thedocumentationstates that for http keepalive, you should also setproxy_http_version 1.1;andproxy_set_header Connection "";
Nginx install intermediate certificate
I'm trying to install an intermediate certificate on Nginx ( laravel forge ). Right now the certificate is properly installed, just the intermediate that is missing.I've seen that I need to concatenate the current certificate with the intermediate. What is the best/safest way to add the intermediate certificate.Also, i...
Nginx expects allserversection certificates in a file that you refer withssl_certificate. Just put all vendor's intermediate certificates and your domain's certificate in a file. It'll look like this.-----BEGIN CERTIFICATE----- MII... -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MII... -----END CERTIFICATE----...
How to disallow access to all dot directories except .well-known?
I've got this in my nginx config:location ~ /\. { deny all; } location /.well-known/ { allow all; }But I still can't accesshttp://example.com/.well-known/acme-challenge/taUUGC822PcdnCnW_aADOzObZqFm3NNM5PEzLNFJXRU. How do I allow access to just that one dot directory?
You have a regex location and a prefix location. The regex location takes precedence unless^~is used with the prefix location. Try:location ~ /\. { deny all; } location ^~ /.well-known/ { # allow all; }Seethis documentfor details.
Express - req.ip returns 127.0.0.1
I have my express server running on port 3000 with nginx for the reverse proxy.req.ip always returns 127.0.0.1 and req.ips returns an empty arrayapp.enable('trust proxy');With/without enabling trust proxy, x-forwarded-for doesn't work:var ip_addr = req.headers['X-FORWARDED-FOR'] || req.connection.remoteAddress;nginx co...
You need to pass the appropriateX-Forwarded-Forheader to your upstream. Add these lines to your upstream config:proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
How to turn off or specify the nginx error log location?
I compiled the nginx on Ubuntu myself. I start my nginx with -c nginx.conf parameter. In my nginx.conf file, I try to turn off error log with but failed.error_log /dev/null crit;Still got the error message: nginx: [alert] could not open error log file: open() "/usr/nginx/logs/error.log" failed (2: No such file or direc...
The syntax for disabling the error log is ok, but thedocsstate that a default logfile is used before the config is read. (which seems reasonable because how would it otherwise tell you you have an error in your config)Try creating this file by hand with the correct permissions for the user that runs nginx. Or try start...
Serving Python (Flask) REST API over HTTP2
I have a Python REST service and I want to serve it using HTTP2. My current server setup isnginx -> Gunicorn. In other words, nginx (port 443 and 80 that redirects to port 443) is running as a reverse proxy and forwards requests to Gunicorn (port 8000, no SSL). nginx is running in HTTP2 mode and I can verify that by us...
Is it possible to serve a Python (Flask) application with HTTP/2?Yes, by the information you provide, you are doing it just fine.In my case (one reverse proxy server and one serving the actual API), which server has to support HTTP2?Now I'm going to tread on thin ice and give opinions.The way HTTP/2 has been deployed s...
ERR_TOO_MANY_REDIRECTS with nginx
I want to redirect all myhttptraffic to redirect tohttps. I am usingletsencrypt. I read online thatreturn 301 https://$server_name$request_uri;would redirect all the traffic to my website over tohttpsbut instead it results inERR_TOO_MANY_REDIRECTS.Everything works fine without the above mention statement, but then I ha...
Change your config to belowserver { listen 80 default_server; server_name mywebsite.me www.mywebsite.me; return 301 https://$server_name$request_uri; } server { listen 443 ssl default_server; ssl_certificate /etc/letsencrypt/live/mywebsite.me/fullchain.pem; ssl_certif...
How to setup mass dynamic virtual hosts in nginx?
Been playing with nginx for about an hour trying to setup mass dynamic virtual hosts. If you ever done it in apache you know what I mean.Goal is to have dynamic subdomains for few people in the office (more than 50)
You will need some scripting knowledge to put this together. I would use PHP, but if you are good in bash scripting use that. I would do it like this:First create some folder (/usr/local/etc/nginx/domain.com/).In main nginx.conf add command :include /usr/local/etc/nginx/domain.com/*.conf;Every file in this folder shoul...
"Operation not permitted" from docker container logged as root
I need your help to understand my problem.I updated my macintosh with Catalina last week, then i updated docker for mac.Since those updates, i have ownership issues on shared volumes.I can reproduce with a small example. I just create a small docker-compose which build a nginx container. I have a folder src with a PHP...
If it was working prior to the update to Catalina, the issue is due to the new permissions requested by Catalina.Now, macOS requests permissions for everything, even for accessing a directory. So, probably you had a notification about granting Docker for Mac permission to access the shared folder, you didn't grant it, ...
Is there any way to configure nginx (or other quick reverse proxy) dynamically?
Suppose we have several identical nodes which are the application servers of some n-tier service. And suppose we use Apache ZooKeeper to keep all the config's of our distributed application. Plus we have an nginx as a load balancer and reverse proxy in front of this application.So let's say we perform a command which c...
Nginx has two methods of changing configuration:HUPsignal to the master process results in "reload". Nginx starts a bunch of new workers and lets the old workers to shutdown gracefully, i.e. they finish existing requests. There isnointerruption of service. This method of configuration change is very lightweight and qui...
PHP FPM returns HTTP 500 for all PHP errors [duplicate]
This question already has answers here:How do I get PHP errors to display?(27 answers)Closed6 months ago.I am running nginx with PHP-FPM. My nginx configuration for handling php files looks like this:location ~ \.php$ { set $php_root /home/me/www; fastcgi_pass 127.0.0.1:9000; fast...
Try to find the following line in yourphp.ini:display_errors = Offthen make it on
nginx 301 redirect with query string
Currently I have something like this in my nginx.conf file:location ~ /old/page/?$ { return 301 /new-page; }The issue is that query strings are being stripped from the /old/page?ref=xx URL.Is it possible to include query strings using the redirect method I'm using above?
Anything from the?and after is the query string and is not part of the normalised URI used inlocationandrewritedirectives. Seethis documentfor details.If you want to keep the query string, either add it to thereturn:location = /old/page/ { return 301 /new/page$is_args$args; }Or withrewrite, the query string is auto...
Nginx - Rewrite the request_uri before uwsgi_pass
I have a Nginx vhost than is configured as such:... location /one { include uwsgi_params; uwsgi_pass unix:///.../one.sock; } location /two { include uwsgi_params; uwsgi_pass unix:///.../two.sock } ...This is a simplified configuration of courseWhen I request/one/somethingI would like my Python script to receive...
location /one { rewrite /one/(.+) /$1 break; include uwsgi_params; uwsgi_pass unix:///.../one.sock; }
nginx errors readv() and recv() failed
I use nginx along with fastcgi. I see a lot of the following errors in the error logsreadv() failed (104: Connection reset by peer) while reading upstream and recv() failed (104: Connection reset by peer) while reading response header from upstreamI don't see any problem using the application. Are these errors ...
I was using php-fpm in the background and slow scripts were getting killed after a said timeout because it was configured that way. Thus, scripts taking longer than a specified time would get killed and nginx would report a recv or readv error as the connection is closed from the php-fpm engine/process.
nginx reverse proxy websockets
nginx now supports proxying websockets, but I was unable to find any information on how to do this without having a separatelocationblock that applies to URIs on which websockets are used.I've seen some folks recommending some variations of this approach:location / { proxy_http_version 1.1; proxy_set_header ...
Why doesn't nginx just forward the original Upgrade/Connection headers?From theofficial documentation:since the “Upgrade” is a hop-by-hop header, it is not passed from a client to proxied serverSeeRFC 2616.I don't want the Upgrade header or Connection being set to "upgrade" unless that's what the browser sent,There is ...
Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs [duplicate]
This question already has answers here:What is the location of Laravel's error logs?(6 answers)Closed13 days ago.Git repo of project:https://github.com/tombusby/docker-laravel-experiments(HEAD at time of writing is 823fd22).Here is my docker-compose.yml:nginx: image: nginx:stable volumes: - ./nginx.conf:/etc/ng...
As per our discussion in ##php on freenode...Your issue is that the php.ini setting "log_errors" is set to Off.your options are:set log_errors=On in php.iniset php_admin_flag[log_errors]=On in your pool config (for docker container based onphp:5.6-fpmthat is in the file/usr/local/etc/php-fpm.conf)or possibly set log_er...
Difference between Gunicorn and Nginx
This is a beginer question, but I am having trouble understanding the abstraction between Gunicorn and Nginx. I am not looking for a detailed answer, just at a high level what is the role that each plays? How do they interact?
PerGunicorn's deploy doc, my understanding is that you use Nginx as a proxy server for Gunicorn.As Gunicorn is ported fromRuby's Unicorn, I'm assuming the limitations and specifications of Unicorn apply to Gunicorn as well:Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-late...
Nginx: directly return $remote_addr in text/plain
It may sound like a code golf question, but what is the simplest / lightest way to return$remote_addrintext/plain?So, it should return several bytes of the IP address in a plain text.216.58.221.164Use case: An API to learn the client's own external (NAT), global IP address.Is it possible to do it with Nginx alone and w...
The simplest way is:location /remote_addr { default_type text/plain; return 200 "$remote_addr\n"; }The above should be added to theserverblock of yournginx.conf.No need to use any 3rd party module (echo, lua etc.)
How to serve Flask static files using Nginx?
I've a web application with this structure:| |__ static |__style.less |__images |__ myapp.py |__ wsgi.pyI've managed to run the web application using nginx and wsgi, but the problem is that the static files are not served, i mean, the server can't find them when i go to their URL. It gives me 404.Here's my nginx ...
Add this to your nginx configurationlocation ^~ /static/ { include /etc/nginx/mime.types; root /project_path/; }replace/project_path/with yourapp's absolute path, you should note that itdoesn't include static directoryand all the contents inside/project_path/static/will be serverd in url/static/.
Django whitenoise drawback
There are many article describing the pros of using whitenoise instead of other configuration for serving static files. But the information about it's cons is kind of hard to findIs there any cons or drawbacks of using whitenoise for serving static files?If the question is to broad, I'm now using NGINX for serving my s...
The downside of WhiteNoise is that if you use it without a CDN like Cloudfront or Cloudflare it will definitely not perform as well as nginx. WhiteNoise is best either when used with a CDN (as most production sites ought to be doing) or for low-traffic sites where ease of configuration trumps performance.If you already...
How to make URL case insensitive with Nginx
I am using Nginx for a simple demo website, and I just configure the Nginx like this:server { listen 80; server_name www.abc.com; location / { index index.html; root /home/www.abc.com/; } }In mywww.abc.comfolder, I have sub-folder namedSub, and inside h...
server { # Default, you don't need this! #listen 80; server_name www.abc.com; # Index and root are global configurations for the whole server. index index.html; root /home/www.abc.com/; location / { location ~* ^/sub/ { # The tilde and...
recommended nginx configuration for meteor
The site configuration for my meteor app has directives which look like the following:server { listen 443; server_name XXX; ssl on; ssl_certificate XXX; ssl_certificate_key XXX; location / { proxy_pass http://localhost:3000; proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpPro...
Although I'm not an nginx expert, I feel like I have a much better understanding of how to do this now. As I figure out more I'll update this answer.One possible solution to my original question is this:location ~* "^/[a-z0-9]{40}\.(css|js)$" { root /home/ubuntu/app/bundle/programs/web.browser; access_log off; ex...
nginx reverse proxy to backend running on localhost
EDIT: It turns out that the my setup below actually works. Previously, I was getting redirections to port 36000 but it was due to some configuration settings on my backend application that was causing it.I am not entirely sure, but I believe I might be wanting to set up a reverse proxy using nginx.I have an application...
EDIT: The config below is from a working nginx config, with the hostname and port changed.You need to may be able to set the server listening on port 36000 as anupstreamserver (seehttp://nginx.org/en/docs/http/ngx_http_upstream_module.html).server { listen 80; server_name domain.somehost.com; ...
Nginx unknown directive "if($domain"
Nginx Complains about the following part of my configuration:nginx: [emerg] unknown directive "if($domain" in /etc/nginx/nginx.conf:38 nginx: configuration file /etc/nginx/nginx.conf test failedHere is the bit it is talking about:server_name ~^(?:(?\w*)\.)?(?\w+)\.(?(?:\w+\.?)+)$; if($domain = "co") { set ...
Hopefully you have this solved by now but for anyone else who is struggling with a similar issue. You need to include a space between the if statement and the opening parenthesis.So in your example you need to change the lineif($domain = "co") {toif ($domain = "co") {And everything should work fine.
Hide a client request header with a Nginx reverse proxy server
I have a Nginx websocket reverse proxy and I would like to hide a HTTP header from the client request.proxy_hide_header hides the server response headers and can't be used for hiding client request headers.I would like to do that because the websocket server behind nginx doesn't work well with the websocket extension "...
You can set a header value to void and Nginx will drop it :proxy_set_header Sec-WebSocket-Extensions "";
Nginx request_uri without args
How do I get the value ofrequest_uriwithout the args appended on the end. I know there is aurivariable but I need the original value as the Nginx documentation states:request_uriThis variable is equal to theoriginalrequest URI as received from the client including the args. It cannot be modified. Look at $uri for t...
You're looking for $uri. It does not have $args. In fact, $request_uri is almost equivalent to $uri$args.If you really want exactly $request_uri with the args stripped, you can do this.local uri = string.gsub(ngx.var.request_uri, "?.*", "")You will need to have lua available but that will do exactly what you're asking.
nginx rewrite redirect for a folder
all...I am trying to do something in nginx to redirect all calls for files in/images/to become in:/assets/images/can someone help me with the rewrite rule? giving a 301 moved permanently status?
Here's the preferred way to do this with newer versions of Nginx:location ~ ^/images/(.*) { return 301 /assets/images/$1; }Seehttps://www.nginx.com/blog/creating-nginx-rewrite-rules/for more info.
Nginx proxy_pass : Is it possible to add a static parameter to the URL?
I'd like to add a parameter in the URL in a proxy pass. For example, I want to add an apiKey : &apiKey=tigerhttp://mywebsite.com/oneapi?field=22--->https://api.somewhere.com/?field=22&apiKey=tigerDo you know a solution ?Thank's a lot, Gilles.server { listen 80; server_name mywebsite.com; location /...
location = /oneapi { set $args $args&apiKey=tiger; proxy_pass https://api.somewhere.com; }
Flask 301 Response
My flask app is doing a301redirect for one of the urls.The traceback in New Relic is:Traceback (most recent call last): File "/var/www/app/env/local/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request rv = self.dispatch_request() File "/var/www/app/env/local/lib/python2.7/site-package...
The traceback shows that it was the route matching that raised a redirect;usually(e.g. unless you added explicit redirect routes), that means the client tried to access abranchURL (one that ends with atrailing slash), but the requested URL did not include the last slash. The client is simply being redirected to the can...
How do you serve static files from an nginx server acting as a reverse proxy for a nodejs server?
My current nginx config is this:upstream nodejs { server 127.0.0.1:3000; } server { listen 8080; server_name localhost; root ~/workspace/test/app; index index.html; location / { proxy_pass http://nodejs; proxy_set_header Host $host ; proxy_set_header X-Real-IP $remote_...
I solved it using this new configuration:upstream nodejs { server localhost:3000; } server { listen 8080; server_name localhost; root ~/workspace/test/app; location / { try_files $uri @nodejs; } location @nodejs { proxy_redirect off; proxy_http_version 1.1; ...
How to gracefully restart django running fcgi behind nginx?
I'm running a django instance behind nginx connected using fcgi (by using the manage.py runfcgi command). Since the code is loaded into memory I can't reload new code without killing and restarting the django fcgi processes, thus interrupting the live website. The restarting itself is very fast. But by killing the fcgi...
I would start a new fcgi process on a new port, change the nginx configuration to use the new port, have nginx reload configuration (which in itself is graceful), then eventually stop the old process (you can use netstat to find out when the last connection to the old port is closed).Alternatively, you can change the f...
Nginx return file for path
I want Nginx to return r.json file for path example.com/r/ What I tried:location /r/ { alias /home/user/media/json/r.json; }But all that didn't work. I've got 500 with message:/home/user/media/json/r.jsonindex.html is not a directory
Use theindexdirective to namer.jsonas the default filename within that location:location /r/ { index r.json; alias /home/user/media/json/; }
nginx 'invalid number of arguments in "map" directive'
I'm trying to reverse-proxy a websocket, which I've done with nginx before with no issue. Weirdly, I can't seem to re-create my prior success with something so simple. I've been over and over the config file but can't seem to find my error.Here's my fulldefault.conf:map $http_upgrade $connection_upgrade { default u...
Theenvsubstcommand replaces all occurrences of$vars, including$http_upgradeand$connection_upgrade. You should provide a list of variables to be replaced, e.g.:envsubst '${API_LOCATION},${UI_LOCATION}' < /etc/nginx/conf.templates/default.confSee also:Replacing only specific variables with envsubstMoreover, into theDocke...
Drop unwanted connections
I want to block unwanted Bots from accessing sites on the server.Can nginx drop / kill the connection right away when a certain Bot is detected?if ($http_user_agent ~ (agent1|agent2) ) { **KILL CONNECTION**; }Something like example above.
Use return 444;This non-standard status code of 444 causes nginx to simply close the connection without responding to it.if ($http_user_agent ~ (agent1|agent2) ) { return 444; }Reference documentationMore elaborative documentation
nginx 1.2.0 - socket.io - HTTP/1.1 - Proxy websocket connections
i would like to replace my node-http-proxy module with nginx proxy_pass module. Is it possible with new released nginx version, as i have read, that it supports HTTP/1.1 out of the box. I saw some threads struggeling with that problem, that websockets are not supported by nginx.In my case im running several node projec...
No, this is not yet possible; nginx 1.2 incorporates stuff from the 1.1.x development branch which indeed includes HTTP/1.1 reverse proxying. Websocket connections are established using the HTTP/1.1 "Upgrade" header, but the fact that nginx now supports this kind of headers does not mean it supports websockets (websock...
Why is request_time much larger than upstream_response_time in nginx access.log?
I am trying to improve the performance of a web app. Profiling the app itself, I found its response time are quite acceptable (100ms-200ms), but when I use ApacheBench to test the app, the response time sometimes exceeds 1 second. When I looked closely at the logs, I found a big discrepancy betweenrequest_timeandupstre...
A highrequest_timemay be, among others, due to a client with a slow connection, for which you can't do much about. Thus, a highrequest_timedoesnot necessarilyrepresent the performance of your server and/or application.You really should not spend too much time onrequest_timewhen profiling but instead measure things like...
Can i deploy my .war on an nginx server
I really love nginx for the stability and way requests are handled.And i really love tomcat for the java and the user friendlinessIs there a way to deploy my .war on a nginx server ?
I don't believe this is possible as nginx is not a servlet container, so it has no understanding of what a .war file is. You can configure nginx to act as a reverse proxy in front of a Tomcat server so this might get you the best of both worlds.A quick Google search came up with thishttp://wiki.nginx.org/JavaServerswhi...
Server-Sent Events connection timeout on Node.js via Nginx
I have a Node.js via Nginx setup and it involves Server-Sent Events.No matter what Nginx configuration I have, connection of sse is broken after 60 seconds and reinitialized again. It doesn't happen if I connect to application directly on port on which node serves it, so it's clearly some Nginx proxy issue.I'd like to ...
Answering to myself. Actually solution was not that difficult to find, it just demanded careful look into nginx documentation.proxy_read_timeoutis a directive responsible for that, and by default it's set to 60 seconds. So it can be easily fixed by setting e.g.:proxy_read_timeout 24h;Setting0won't work, it will actuall...
Why won't curl recognise a self-signed SSL certificate?
I copied the PEM file into /usr/local/share/ca-certificates/ and ran update-ca-certificates, and I verified that the resulting certificate is now included in /etc/ssl/certs/ca-certificates.crt which is the file printed by curl-config --ca. I also verified that the certificate printed by openssl s_client -connect examp...
If we usecURLto retrieve aHTTPSsite that is not using aCA-signed certificate, the following problem occurs:curl https://example.selfip.com curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http...
Location of the Nginx default index.html file on MAC OS
I have successfully installed nginx on my MAC with homebrewbrew install nginxbut i can't find from where is this default page called.In nginx.conf under location saysroot html;and i can't find it. Please help.
Lewis4u's answer may be right! But I think we should have a clearer explanationIn nginx.conf file we see the root path is:root html;The question is: Where is "html" relative path? This relative path is set at compile time. You can check the path by command$>nginx -VYou will see "--prefix=/usr/local/Cellar/nginx/1.12...
nginx proxy server localhost permission denied
I am just setting up nginx as a webserver that proxies directly to a tomcat app server. When the user connects to my website Nginx should redirect the request to port 8080 where the tomcat app server is running.I am doing everything on amazon ec2 instance that is running Redhat 7.What I have so far is this:nginx.conf ...
I was able to find a solution after 2 days of searching. Somehow SELinux was not permitting Nginx to proxy to my server. Running the command below fixed the issue./usr/sbin/setsebool -P httpd_can_network_connect trueAdding the -P flag thanks to @DaveTrux
Nginx with Supervisor keep changing status b/w Running and Starting
Here's a preview of the status runningsupervisorctl statusevery 2 seconds:[root@docker] ~ # supervisorctl status nginx RUNNING pid 2090, uptime 0:00:02 [root@docker] ~ # supervisorctl status nginx STARTING [root@docker] redis-2.8.9 # supervisorctl status nginx...
Its been a long time, but it might help someone else... setdaemon offin your nginx config. Supervisord requires processes not to run as daemons.You can also set it directly for the supervisor command:command=/usr/sbin/nginx -g "daemon off;"
nginx log analysis with goaccess
I want to parse and analyze the nginx logs withgoaccessand take a report from the analyzed logs. But, when I run thezcat -f access.log.*.gz | goaccess -a -ccommand, it gives me the following error :GoAccess - version 0.5 - Jun 26 2012 04:30:08 An error has occurred Error occured at: parser.c - process_log - 584 Message...
Got it working with the following~/.goaccessrc:date_format %d/%b/%Y:%T %z log_format %h - - [%d] "%r" %s %b "%R" "%u"I installed GoAccess as a binary package from wheezy repository (no source recompilation).
Why use nginx with Catalyst/Plack/Starman?
I am trying to deploy my little Catalyst web app using Plack/Starman. All the documentation seems to suggest I want to use this in combination with nginx. What are the benefits of this? Why not use Starman straight up on port 80?
It doesn't have to be nginx in particular, but you want some kind of frontend server proxying to your application server for a few reasons:So that you can run the Catalyst server on a high port, as an ordinary user, while running the frontend server on port 80.To serve static files (ordinary resources like images, JS, ...
How to serve images with nginx
I am completely new to nginx and I am asked to find a way to serve Map Tiles that are separated according to the zoom levels. The image file structure is like~/data/images/7/65/70.pngwhere 7 is the zoom level, 65 and 70 are the lon-lat values. The folder 65 contains many files such as 71.png, 72.png and etc.I have inst...
Ok, let me explain something, you already have a localhost server, which is defined inside a file calleddefaultthat is the file that causes the "Welcome to nginx" or something to appear, and I believe you can't create a new server with the sameserver_name, let's remove that and make your localhost serve only those imag...
How can I deploy my Angular 2 + Typescript + Webpack app
I am actually learning Angular 2 with Typescript and developed a little app by based on the angular-seed project (angular-seed). I have built the app for production purposes and got dist folder ready to be deployed containing my bundle files like this:dist/ main.bundle.js main.map ...
You are on the right track.....Just install the nginx on your EC2. In my case I had a linux Ubuntu 14.04 installed on "Digital Ocean".First I updated the apt-get package lists:sudo apt-get updateThen install Nginx using apt-get:sudo apt-get install nginxThen open the default server block configuration file for editing:...
Changing the user that nginx worker processes run under (Ubuntu 12.04)
I have a manual install of nginx on Ubuntu 12.04. When I ran./configureI used the following options:./configure --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_moduleNow the nginx worker processes run under the www-data user in the www-data group. However, I wish to change this to a different...
As long as your new user (nginxin your case) has the proper rights, everything should work.You have to change yourusersetting innginx.conf... user nginx; ...and restart/reload your server.Link to docs.
nginx unknown directive "upstream"
I'm using nginx as a proxy server to forward requests onto my gunicorn server. When I runsudo nginx -t -c /etc/nginx/sites-enabled/mysiteI get the following error.[emerg]: unknown directive "upstream" in /etc/nginx/sites-enabled/mysite:1 configuration file /etc/nginx/sites-enabled/mysite test failedAny idea how to fix ...
Turns my nginx config was ok. The problem was with my gunicorn server was not running properly.
Nested locations in nginx
Hi I'm trying to get the following to work!I'm basically trying to allow the following URLs to be passed to the proxy_pass directive by either of these two URLS:http://example.com/admin/1orhttp://example.com/admin/2/I have the following config:location /admin/ { # Access shellinabox via proxy location ...
You should use/admin/1/in your inner location block as the inner URLs are not relative to the outer URLs. You can see that this is the issue based on the following snippet from the error message you included...location "1/" is outside location "/admin/"
How to add headers to only specific files with nginx
I have pictures, and I want to add their headers to max, I have profile pictures which can be changed and post pictures, I want to add headers only for post pictures, but not to profile pictures, I have no idea how can I manage this. thank you, this is my configuration,this is the path of posts, /post/name-of-the-pictu...
Currently we havetwo optionsto solve this:Option 1:Duplicated locations: NGINX looks for the best match. (a little better performance)location /post/ { post config stuff; . . . } location ~* ^/post/.*\.(css|js|png|gif)$ { post/files.(css|js|png|gif) config stuff; expires max; add_header ...
Configure Nginx to reply to http://my-domain.com/.well-known/acme-challenge/XXXX
I'm not able to get nginx to return the files I've put in/var/www/letsencrypt.nginx/sites-available/mydomain.confserver { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name my-real-domain.com; include /etc/nginx/snippets/letsencrypt.conf; root /var/www/mydomain; index index.h...
Optionroot /var/www/letsencrypt/;tells to nginx "this is base directory", so final path will be/var/www/letsencrypt/.well-known/acme-challenge/.So, you have 2 options:Change your path, for example to$ echo hi > /var/www/letsencrypt/.well-known/acme-challenge/hiChange behavior of nginx, so nginx will treat it as alias:l...
403 Forbidden on nginx/1.4.6 (Ubuntu) - Laravel
I keep getting403 ForbiddenMy settings:/etc/nginx/sites-available/defaultdefaultserver { listen 80; root home/laravel-app/; index index.php index.html index.htm; server_name example.com; location / { try_files $uri $uri/ /index.html; } erro...
You need to specify an absolute path for yourrootdirective. Nginx uses the directory set at compile time using the --prefix switch. By default this is/usr/local/nginx.What this means is that your root, which is currently set to roothome/laravel-app/causes nginx to look for files at/usr/local/nginx/home/laravel-app/whic...
Serve multiple Angular apps from the same server with Nginx
I'm serving multipleangularapps from the sameserverblock inNginx. So in order to let the user browse directly to certain customAngularroutes I've declared without having to go through the home page (and avoid the 404 page), I'm forwarding these routes from nginx to each angular app'sindex.html, I've added atry_filesto ...
It is generally a bad security practice to have multiple independent apps on a single domain.However, I believe what you're facing here is the peculiarity of the way thattry_filesworks -- according tohttp://nginx.org/r/try_files,If none of the files were found, an internal redirect to the uri specified in the last para...
Any good way to programmatically change nginx config file from python?
I have a python script that dynamically alters nginx config file (nginx.conf). Since nginx configuration is not ininiformat, i currently use some regexp to parse and modify file content. Is it the only way or some better way to programmatically alter nginx configuration exist?
Just found out aboutpython-nginx, which works great out-of-the-box using only Python, and doesn't seem to need any C or required Python package at all! Could improve docs a bit. Maybe I'll send a pull request for that.
Sharing precompiled assets across docker containers
I have an nginx container separate from my rails container and want to be able to serve precompiled assets from rails with the nginx container. This sounds like a job for a volume container but I have got myself confused after having quickly needing to learn docker and reading the documentation endlessly. Has anybody h...
I'm having the same issue. Here's what I'm currently working on:Option 1: use a single image for both nginx and the appThis way, I can build the image once (with the app, precompiled assets and nginx), then run two instances of it: one running the app server, and another for the nginx frontend:docker build -t hello . d...
Why is the initial connection time for a HTTP request so long?
My web app sits behind a Nginx. Occasionally, the loading of my web page takes more than 10 seconds, I used Chrome DevTools to track the timing, and it looks like this:The weird thing is, when the page loads slowly, the initial connection time is always 11 seconds long. And after this slow request, subsequent loading o...
The initial connection refers to the time taken to perform the initial TCP handshake and negotiating an SSL (where applicable). The slowness could be caused by congestion, where the server has hit a limit and can't respond to new connections while existing ones are pending. You could look into someperformance enhanceme...
Rate limit in nginx based on http header
Maybe I am asking a poor question but I want to apply rate limit in nginx based on custom http header rather than IP based. My IP based configuration is working but I am not able to get around using custom http header. What I want is that if a particular header is present in http request then rate limiting should be ap...
I think you can manage this with map. If the header is present, map a variable to either the IP of the client or to an empty string, and use that value as the key of the zone. If the map does not match, the empty string will prevent rate limiting from happening.Something like this (not tested, but should work)map $http...
nginx and Perl: FastCGI vs reverse proxy (PSGI/Starman)
A very popular choice for running Perl web applications these days seems to be behind a nginx webserver proxying requests to either a FastCGI daemon or a PSGI enabled webserver (e.g. Starman).There have been lots of question as to why one would do this in general (e.g.Why use nginx with Catalyst/Plack/Starman?) and th...
A reverse proxy setup (e.g. nginx forwarding HTTP requests to Starman) has the following advantages:things are a bit easier to debug, since you can easily hit directly the backend server;if you need to scale your backend server, you can easily use something like pound/haproxy between the frontend (static-serving) HTTP ...
Custom nginx.conf from ConfigMap in Kubernetes
I have Kubernetes set up in a home lab and I am able to get a vanilla implementation of nginx running from a deployment.The next step is to have a custom nginx.conf file for the configuration of nginx. For this, I am using a ConfigMap.When I do this, I no longer receive the nginx index page when I navigate tohttp://19...
Nothing complex, it's the root directory in thenginx.confis not defined correctly.Checking the logs withkubectl logs <> -n <>gives why the404 erroris happening for a particular request.xxx.xxx.xxx.xxx - - [02/Oct/2020:22:26:57 +0000] "GET / HTTP/1.1" 404 153 "-" "curl/7.58.0" 2020/10/02 22:26:57 [error] 28#28: *1 "/etc...
Create kubernetes nginx ingress without GCP load-balancer
So I'm using Kubernetes for a side project and it's great. It's cheaper to run for a small project like the one I'm on (a small cluster of 3-5 instances gives me basically everything I need for ~$30/month on GCP).The only area where I'm struggling is in trying to use the kubernetes Ingress resource to map into cluster ...
Yes this is possible. Deploy your ingress controller, and deploy it with a NodePort service. Example:--- apiVersion: v1 kind: Service metadata: name: nginx-ingress-controller namespace: kube-system labels: k8s-app: nginx-ingress-controller spec: type: NodePort ports: - port: 80 targetPort: 80 no...
Docker production ready php-fpm and nginx configuration
I have a small theoretical problem with combination of php-fpm, nginx and app code in Docker.I'm trying to stick to the model when docker image does only one thing -> I have separate containers for php-fpm and nginx.php: image: php:5-fpm-alpine expose: - 9000:9000 volumes: - ./:/var/www/app ...
At this time I use smth like:Dockerfile:FROM php:fpm COPY . /var/www/app/ WORKDIR /var/www/app/ RUN composer install EXPOSE 9000 VOLUME /var/www/app/webDockerfile.nginxFROM nginx COPY default /etc/nginx/defaultdocker-compose.ymlapp: build: context: . web: build: context: . dockerfile: Dockerfile.nginx ...
How do i configure nginx to redirect to a url for robots.txt & sitemap.xml
I am running nginx 0.6.32 as a proxy front-end for couchdb. I have my robots.txt in the database, reachable ashttp://www.example.com/prod/_design/mydesign/robots.txt. I also have my sitemap.xml which is dynamically generated, on a similar url.I have tried the following config:server { listen 80; server_name example...
Or you can put it simply in its own location -location /robots.txt { alias /Directory-containing-robots-file/robots.txt; }
How to install nginx 1.9.15 on amazon linux disto
I try to install the latest version of nginx (>= 1.9.5) on a fresh amazon linux to make use of http2. I followed the instructions that are described here ->http://nginx.org/en/linux_packages.htmlI created a repo file/etc/yum.repos.d/nginx.repowith this content:[nginx] name=nginx repo baseurl=http://nginx.org/packages/m...
If you're using AWS Linux2, you have to install nginx from the AWS "Extras Repository". To see a list of the packages available:# View list of packages to install amazon-linux-extras listYou'll see a list similar to:0 ansible2 disabled [ =2.4.2 ] 1 emacs disabled [ =25.3 ] 2 memcached1.5 disabled [ =1.5.1 ]...
nginx proxy_pass based on whether request method is POST, PUT or DELETE
I have twoiKaaroinstances running on port 8080 and 9080, where the 9080 instance is Read only.I am unsure how to use nginx for example if the request method is POST, PUT, DELETE then send to write instance (8080) else send to 9080 instance.I have done something using the location using the regex, but this is not correc...
I just did a quick test, and this worked for me:server { location / { # This proxy_pass is used for requests that don't # match the limit_except proxy_pass http://127.0.0.1:8080; limit_except PUT POST DELETE { # For requests that *aren't* a PUT, POST, or DELETE, # pass to :9080 prox...
Django + uWSGI via NGINX on Ubuntu 11.10
I'm trying do deploy a django project. I tried a lot of tutorials, but had no luck. I use a new clean Ubuntu 11.10. I've performedapt-get install nginx apt-get install uwsgi service nginx startI've created folder/deploy/project1and put theremanage.pyand other files.My current/deploy/project1/project1/wsgi.pycontains:im...
Assuming that you have installed all requirement and you are using the aptitude packages then you don't need the wsgi.py. All the configuration is in the uwsgi ini/xml/yaml file. (take the format that you prefer).Here is a minimal example forexample.comfile for nginx(/etc/nginx/sites-available/examplecom for ubuntu 11...
nginx $scheme variable behind load balancer
Is it possible to force nginx$schemevalue to "https" if nxinx is running behind load balancer?In my scenario Load balancer takes care of https communication with client and forwards requests to nginx as raw http. I know I can do something like this to detect httpsset $my_scheme "http"; if ($http_x_forwarded_proto = "ht...
Our setup is the same as yours, only usingmapinstead ofif/set(as recommended by thenginx devs).# Sets a $real_scheme variable whose value is the scheme passed by the load # balancer in X-Forwarded-Proto (if any), defaulting to $scheme. # Similar to how the HttpRealIp module treats X-Forwarded-For. map $http_x_forwarded...
How to match question mark "?" as regexp on nginx.conf location
I'd like to match question mark "?" as regexp on nginx.conf location.For example, a URL pattern which I'd like to match is /something?foo=5 or /something?bar=8 (parameter only changeable).Because nginx adoptsRCPE, I can write the location on nginx.conf as follows:location ~ ^/something\?.* { }The above doesn't match th...
nginxlocation block doesn't match query stringat all. So it's impossible.LocationThis directive allows different configurations depending on the URI.In nginx, there is a built-in variable$uri, which the location block is matched against. For example, give a requesthttp://www.example.com/app/login.php?username=xyz&passw...
nginx keep port number when 301 redirecting
I'm trying to collapse a second brand of a web app into the first brand and use 301 redirects to redirect any lingering traffic. The server is running in a Vagrant box forwarding on port 8001. I would like to have:Instead ofhttps://local-dev-url:8001/foo/(anything)301 tohttps://local-dev-url:8001/(anything)Instead ofht...
Ifnginxis not listening on port 8001, it cannot know which port to use in the redirect. You will need to specify it explicitly:location ~ /foo(.*)$ { return 301 $scheme://$http_host$1; } location ~ /adminfoo(.*)$ { return 301 $scheme://$http_host/admin$1; }The$http_hostvariable consists of the hostname and port...
Nginx connection reset, response from uWsgi lost
I have a django app hosted via Nginx and uWsgi. In a certain very simple request, I get different behaviour for GET and POST, which should not be the case.The uWsgi daemon log:[pid: 32454|app: 0|req: 5/17] 127.0.0.1 () {36 vars in 636 bytes} [Tue Oct 19 11:18:36 2010] POST /buy/76d4f520ae82e1dfd35564aed64a885b/a_2/10/ ...
After a lucky find in further research (http://answerpot.com/showthread.php?577619-Several%20Bugs/Page2) I found something that helped...Supplying theuwsgi_pass_request_body off;parameter in the Nginx conf resolves this problem...
how to start puma with unix socket
I have followedthis linkto configure nginx with puma but when I start the server withbundle exec puma -e development -b unix:///var/run/my_app.sockit throwsPermission denied - "/var/run/my_app.sock" (Errno::EACCES) error.but when I start the server withbundle exec puma -e developmentit is started withtcp://0.0.0.0:9292...
To start puma with socket binding just use/tmpdirectory:bundle exec puma -e development -b unix:///tmp/my_app.sockTo access application through domain name you should use something likenginxand do configuration for it.To installnginxin Ubuntu just run next command:sudo apt-get install nginxRunsudo nano /etc/nginx/sites...
How to change the nginx process user of the official docker image nginx?
I'm using Docker Hub's official nginx image:https://hub.docker.com/_/nginx/The user of nginx (as defined in /etc/nginx/nginx.conf) isnginx. Is there a way to make nginx run aswww-datawithout having to extend the docker image? The reason for this is, I have a shared volume, that is used by multiple containers -php-fpmth...
FYIIt is problem of php-fpm imageIt is not about usernames, it is about www-data user IDWhat to doFix your php-fpm container and don't break good nginx container.SolutionsHere is minepost with solution for docker-compose(nginx + php-fpm(alpine)):https://stackoverflow.com/a/36130772/1032085Here is minepost with solution...
nginx server_name inside stream block possible?
Current setup as follows:stream { server { listen 9987 udp; server_name subdomain.EXAMPLE.com; # this line is resulting in an error proxy_pass localhost:9987; proxy_timeout 1s; proxy_responses 1; error_log logs/dns.log; } }server_name subdomain.EXAMPLE.com;Is ...
TCP has no concept of server names, so this is not possible. It only works in HTTP because the client sends the hostname it is trying to access as part of the request, allowing nginx to match it to a specific server block.Source:https://forum.nginx.org/read.php?2,263208,263217#msg-263217
Flask application traceback doesn't show up in server log
I'm running my Flask application with uWSGI and nginx. There's a 500 error, but the traceback doesn't appear in the browser or the logs. How do I log the traceback from Flask?uwsgi --http-socket 127.0.0.1:9000 --wsgi-file /var/webapps/magicws/service.py --module service:app --uid www-data --gid www-data --logto /var/...
Run in development mode by setting theFLASK_ENVenvironment variable todevelopment. Unhandled errors will show a stack trace in the terminal and the browser instead of a generic 500 error page.export FLASK_ENV=development # use `set` on Windows flask runPrior to Flask 1.0, useFLASK_DEBUG=1instead.If you're still usinga...
nginx redirect all directories except one
I'm using nginx 1.0.8 and I'm trying to redirect all visitors from www.mysite.com/dir to google search pagehttp://www.google.com/search?q=dirwhere dir is a variable, however if dir=="blog"( www.mysite.com/blog) I just want to load the blog content(Wordpress).Here is my config :location / { root html; ...
location / { rewrite ^/(.*)$ http://www.google.com/search?q=$1 permanent; } location /blog { root html; index index.php; try_files $uri $uri/ /blog/index.php; }Explanation:Alocationcan be followed by a path string (calledprefix string) or by aregex.Regex starts with~(for case sensitive matching...
Django: Serving Media Behind Custom URL
So I of course know that serving static files through Django will send you straight to hell but I am confused on how to use a custom url to mask the true location of the file using Django.Django: Serving a Download in a Generic Viewbut the answer I accepted seems to be the "wrong" way of doing things.urls.py:url(r'^son...
To expand on the previous answers you should be able to modify the following code and have nginx directly serve your download files whilst still having the files protected.First of all add a location such as :location /files/ { alias /true/path/to/mp3/files/; internal; }to your nginx.conf file (the internal makes...
Unable to use environment variables in Lua code
I have some Lua code, which I use in my openresty nginx.conf file. This Lua code contains such lines:... local secret = os.getenv("PATH") assert(secret ~= nil, "Environment variable PATH not set") ...Just for testing reasons I tried to check if PATH variable is set and for some reason the assert statement does not pass...
You need to tell nginx to make environment variables available. From thedocs for theenvdirective: "By default, nginx removes all environment variables inherited from its parent process except the TZ variable. This directive allows preserving some of the inherited variables, changing their values, or creating new enviro...
No live upstreams while connecting to upstream, but upsteam is OK
I have a really weird issue with NGINX.I have the followingupstream.conffile, with the following upstream:upstream files_1 { least_conn; check interval=5000 rise=3 fall=3 timeout=120 type=ssl_hello; server mymachine:6006 ; }In locations.conf:location ~ "^/files(?.+)/[0123]" { rewrite ^ $command bre...
When definingupstreamNginx treats the destination server and something that can be up or down. Nginx decides if your upstream is down or not based onfail_timeout(default 10s) andmax_fails(default 1)So if you have a few slow requests that timeout, Nginx can decide that the server in your upstream is down, and because yo...
Nginx to serve static page before dynamic
I want to serve static HTML files with NGINX, but if the file is missing, it should load a PHP file instead and PHP should handle the content.I've been testing several combinations oftry_files, but I can't get my head around it. I have a dummy PHP app that looks like this:./ ../ dynamic.php index.php static/ static/sta...
I would use your static directory as document root. This ensures that nobody can execute/dynamic.phpdirectly, however, it will be forwarded to yourindex.phpby the named location block@php.This configuration example is untested!server { index index.php; root /var/www/foo/static; server_name foo....
proxy_pass isn't working when SELinux is enabled, why?
I'm having an application listening on port 8081 and Nginx running on port 8080. The proxy pass statement looks like:$ cat /var/etc/opt/lj/output/services/abc.servicemanager.conf location /api/abc.servicemanager/1.0 { proxy_pass http://localhost:8081;}Innginx.conf, I include this file as:include /etc/nginx/conf.d/...
Read about audit2allow and used it to create a policy to allow access to the denied requests for Nginx.Step 1 involves runningaudit2allowtargeting nginxlocalconf:$ sudo grep nginx /var/log/audit/audit.log | \ grep denied | audit2allow -m nginxlocalconf > nginxlocalconf.teStep 2, review results:$ cat nginxlocalconf...
NGINX and Angular 2
My current app users routes like this /myapp/, /myapp//, /myaapp/dept/My app is currently deployed in an internal http server with NGINX. The other server that accepts external traffic, also runs NGINX and forwards it to the internal server.I have add baseref=/myapp to the index.html as per documentationIf the user goe...
I just had this same issue and found a solution. My base href is "/", however.Below is my nginx.conf:worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { l...
413 request entity too large + The web server connection was closed | Error 64
I'm currently hosting a django project on Apache + nginx. When I try to upload a large file I get a413 request entity too large error message.I also have a django-cms project and when I tried to upload a file which is anything over 5meg I get an errorcode 64, The web server connection was closed.Thanks in advance,
Your error message tells it comes from nginx configuration.You need to increaseclient_max_body_sizeon yournginx.confserver config. eg :http { server { client_max_body_size 20M; listen 80; server_name test.com; } }
https redirect for rails app behind proxy?
server declaration in my nginx.conf:listen 1.2.3.4:443 ssl; root /var/www/myapp/current/public; ssl on; ssl_certificate /etc/nginx-cert/server.crt; ssl_certificate_key /etc/nginx-cert/server.key; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; prox...
You need to add the following line:proxy_set_header X-Forwarded-Proto https;as inlocation / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_redirect off; if (!-f $request_filename) { p...
Nginx upstream to https host - ssl3_get_record:wrong version number
I am trying to proxy requests to a remote server, this is how I configure my Nginxupstream myupstream { server remote-hostname; }...location ~ ^/(v1|v2|v3)/.*$ { proxy_pass https://myupstream; # also tried these options: # proxy_ssl_server_name on; # proxy_ssl_verify off; # proxy_set_header Host...
upstream: "https://:80/v1/some/page",It is not really clear to me what you are trying to achieve. But it is very unlikely that you have a HTTPS server on port 80. Port 80 is commonly used by HTTP not HTTPS. Trying to access it by HTTPS will usually result in a HTTP error response by the server which, when interpreted a...
How to block all file extensions of certain types on nginx
I run a number of websites behind an nginx frontend. All my sites are in Python/Django. I see in my logs lots of crawling by hackers for various php applications - I'd like to block them (return a 404) at nginx without them hitting my application servers.I'd like to do this globally in my nginx conf file so it applies ...
Try:location ~ (\.php$|myadmin) { return 403; }
Nginx restrict domains
Please find the below setting which is placed in/etc/nginx/sites-enabledunder my site domain name. (mysite.lk)server { listen 80; server_name mysite.lk www.mysite.lk; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_pass "htt...
The first server defined in Nginx is treated as thedefault_serverso by just adding one as the default and returning 412 (Precondition Failed) or any another status that best fits your requirements, will help for the subsequent servers to obey theserver_nameserver { listen 80 default_server; listen [::]:80 defau...
Cloudflare throws 524 an error on my server
Wonder why Cloudflare throws an error on my server which is up? I can verify the server is up by visiting the ip in my browser.I checked system log, apache log, no error found. Btw, I just set the domain on a static site.. I can't figure out how to fix it. Googled and found no solution
A 524 error states that CloudFlare was able to make a TCP connection to the origin, but the origin did not reply with a HTTP response before the connection timed out. This means that CloudFlare is able to make a network connection to the origin server, but the origin server took too long to respond to the request.https...
How do I know which linux user Wordpress uses for plugin installation
I'm trying to setup Wordpress to be able to install plugins via SFTP (SSH) on a Centos 6 VPS.I've been able to modifywp-configso it uses the right credentials withuseras my SFTP user.Now I have a permission related problem, as if I do achmod 777on mywp-contentfolder I'm able to install, but with the normal permissions ...
On your production server, in your WordPress index.php file, at the top, you can temporarily putecho(exec("whoami"));die();Then browse to your WordPress site and see what user was running. On Ubuntu, mine waswww-data.This was useful for me for:Can I install/update WordPress plugins without providing FTP access?
Cache a static file in memory forever on Nginx?
I have Nginx running in a Docker container, and it serves some static files. The files willneverchange at runtime - if they actually do change, the container will be stopped, the image will be rebuilt, and a new container will be started.So, to improve performance, it would be perfect if Nginx would read the static fil...
Operating system does in memory caching by default. It's calledpage cache. In addition, you can enablesendfileto avoid copying data between kernel space and user space.
Serving files stored in S3 in express/nodejs app
I have app where user's photos are private. I store the photos(thumbnails also) in AWS s3. There is a page in the site where user can view his photos(i.e thumbnails). Now my problem is how do I serve these files. Some options that I have evaluated are:Serving files from CloudFront(or AWS) using signed url generation. B...
i would just stream it from S3. it's very easy, and signed URLs are much more difficult. just make sure you set thecontent-typeandcontent-lengthheaders when you upload the images to S3.var aws = require('knox').createClient({ key: '', secret: '', bucket: '' }) app.get('/image/:id', function (req, res, next) { ...
C language FastCGI with Nginx
I am attempting to run a fastcgi app written in C language behind the Nginx web server. The web browser never finishes loading and the response never completes. I am not sure how to approach it and debug. Any insight would be appreciated.The hello world application was taken from fastcgi.com and simplified to look like...
You need to callFCGI_Acceptin thewhileloop:while(FCGI_Accept() >= 0)You haveFCGI_Accept >= 0in your code. I think that results in the address of theFCGI_Acceptfunction being compared to0. Since the function exists, the comparison is never false, but the function is not being invoked.
What does error mean? : "Forbidden (Referer checking failed - no Referer.):"
I have a website running, which appears to be working fine. Yet, now I've seen this error in the logs for the fist time.Forbidden (Referer checking failed - no Referer.): /pointlocations/ [pid: 4143|app: 0|req: 148/295] 104.176.70.209 () {48 vars in 1043 bytes} [Wed Jul 26 19:49:35 2017] POST /pointlocations/?participa...
TLDR: Try to use thecsrf_exemptdecorator for your view:from django.views.decorators.csrf import csrf_exempt @csrf_exempt def my_webhook(request): # Do some stuffs... # Return an HHTPResponse as Django expects a response from the view return HttpResponse(status=200)You should only do this when absolutely n...
Docker registry login fails with "Certificate signed by unknown authority"
I'm am running a private docker registry on ubuntu using S3 for storage. I'm having issues getting docker login/push/pull commands to work over SSL. I'm using Nginx in front of Gunicorn to run the registry. It works without any issues over HTTP, but after switching to HTTPS for a prod system, it throws the following...
For cheap / lesser known certs like the COMODO or StartSSL ones, you need to add the entire certificate chain into the certificate file you are using with nginx. Many operating systems don't trust the intermediate CAs, just the root CA, so you need to fill in the missing steps between the certificate for your host and...
How nginx reload work ? why it is zero-downtime
refer to nginx official docs . the reload command of nginx is for reload of configuration files ,and during the progress , there's no downtime of the service .i've learned that it wait requests that already connected until it finished ,and stop accept any new request . the idea is cool , but how does it deal with the ...
Here's the summary:http://nginx.org/en/docs/control.htmlThe master process first checks the syntax validity, then tries to apply new configuration. If this succeeds, it starts new worker processes, and sends messages to old worker processes requesting them to shut down gracefully.That means it would keep older pr...
nginx ingress sub path redirection
I have an ingress controller and ingress resource running with all /devops mapped to devopsservice in the backend. When I try to hit "http://hostname/devops" things work and I get a page (although without CSS and styles) with a set of hyperlinks for e.g one of them is "logs".When I click on the "logs" hyperlink, it is ...
If you accesshttp://hostname/devops/logsdirectly from your browser, certainly you will get what you want. But since you click the hyperlink in the homepage, then you can only gethttp://hostname/logs, which will be certainly failed.So, you need/logsbackend configured in your ingress yaml to get it processed, and configu...
What is the Best way to Setup Proxy Pass in an Nginx Ingress object for Kubernetes
Currently I am trying to Migrate a site that was living on an Apache Load balanced Server to my k8s cluster. However the application was set up strangely with a proxypass and proxyreversepass like so:ProxyPass /something http://example.com/something ProxyPassReverse /something http://example.com/somethingAnd I would li...
Firstly you can use custom configuration for your nginx ingress controller, documentation can be foundhereAlso, if you just want to use nginx ingress controller as a reverse proxy, each ingress rule already createsproxy_passdirective to relevant upstream/backend service.And if paths are same with your rule and backend ...