Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Nginx 403 error: directory index of [folder] is forbidden | I have 3 domain names and am trying to host all 3 sites on one server (a Digital Ocean droplet) using Nginx.mysite1.name
mysite2.name
mysite3.nameOnly 1 of them works. The other two result in 403 errors (in the same way).In my nginx error log, I see:[error] 13108#0: *1 directory index of "/usr/share/nginx/mysite2.name... | Here is the config that works:server {
server_name www.mysite2.name;
return 301 $scheme://mysite2.name$request_uri;
}
server {
#This config is based on https://github.com/daylerees/laravel-website-configs/blob/6db24701073dbe34d2d58fea3a3c6b3c0cd5685b/nginx.conf
server_name mysite2.name;
# The loca... |
How can I have same rule for two locations in NGINX config? | How can I have same rule for two locations in NGINX config?I have tried the followingserver {
location /first/location/ | /second/location/ {
..
..
}
}but nginx reload threw this error:nginx: [emerg] invalid number of arguments in "location" directive** | Trylocation ~ ^/(first/location|second/location)/ {
...
}The~means to use a regular expression for the url. The^means to check from the first character. This will look for a/followed by either of the locations and then another/. Quoting fromthe docs,A regular expression is preceded with the tilde (~) for case-sensit... |
nginx missing sites-available directory | I installed Nginx on Centos 6 and I am trying to set up virtual hosts. The problem I am having is that I can't seem to find the/etc/nginx/sites-availabledirectory.Is there something I need to do in order to create it? I know Nginx is up and running because I can browse to it. | Well, I think nginx by itself doesn't have that in its setup, because the Ubuntu-maintained package does it as a convention to imitate Debian's apache setup. You could create it yourself if you wanted to emulate the same setup.Create/etc/nginx/sites-availableand/etc/nginx/sites-enabledand then edit thehttpblock inside... |
Have nginx access_log and error_log log to STDOUT and STDERR of master process | Is there a way to have the master process log to STDOUT STDERR instead of to a file?It seems that you can only pass a filepath to the access_log directive:access_log /var/log/nginx/access.logAnd the same goes for error_log:error_log /var/log/nginx/error.logI understand that this simply may not be a feature of nginx, I... | Edit:it seems nginx now supportserror_log stderr;as mentioned inAnon's answer.You can send the logs to/dev/stdout. Innginx.conf:daemon off;
error_log /dev/stdout info;
http {
access_log /dev/stdout;
...
}edit: May need to runln -sf /proc/self/fd /dev/if using running certain docker containers, then use/dev/fd/1or/... |
What's the difference of $host and $http_host in Nginx | In Nginx, what's the difference between variables$hostand$http_host. | $hostis a variable of theCoremodule.$hostThis variable is equal to line Host in the header of request or
name of the server processing the request if the Host header is not
available.This variable may have a different value from $http_host in such
cases: 1) when the Host input header is absent or has an empty value,
$h... |
Nginx 403 forbidden for all files | I have nginx installed with PHP-FPM on a CentOS 5 box, but am struggling to get it to serve any of my files - whether PHP or not.Nginx is running as www-data:www-data, and the default "Welcome to nginx on EPEL" site (owned by root:root with 644 permissions) loads fine.The nginx configuration file has an include directi... | One permission requirement that is often overlooked is a user needs x permissions in every parent directory of a file to access that file. Check the permissions on /, /home, /home/demo, etc. for www-data x access. My guess is that /home is probably 770 and www-data can't chdir through it to get to any subdir. If it ... |
nginx: [emerg] "server" directive is not allowed here | I have reconfigured nginx but I can't get it to restart using the following configuration:server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/access.log;
error_log /var/log/... | That is not an nginx configuration file. It ispartof an nginx configuration file.The nginx configuration file (usually callednginx.conf) will look like:events {
...
}
http {
...
server {
...
}
}Theserverblock is enclosed within anhttpblock.Often the configuration is distributed across multiple f... |
How to redirect to a different domain using Nginx? | How can I redirectmydomain.exampleand any subdomain*.mydomain.exampletowww.adifferentdomain.exampleusing Nginx? | server_namesupports suffix matches using.mydomain.examplesyntax:server {
server_name .mydomain.example;
rewrite ^ http://www.adifferentdomain.example$request_uri? permanent;
}or on any version 0.9.1 or higher:server {
server_name .mydomain.example;
return 301 http://www.adifferentdomain.example$request_uri;
} |
React-router and nginx | I am transitioning my react app from webpack-dev-server to nginx.When I go to the root url "localhost:8080/login" I simply get a 404 and in my nginx log I see that it is trying to get:my-nginx-container | 2017/05/12 21:07:01 [error] 6#6: *11 open() "/wwwroot/login" failed (2: No such file or directory), client: 172.20.... | The location block in your nginx config should be:location / {
try_files $uri /index.html;
}The problem is that requests to the index.html file work, but you're not currently telling nginx to forward other requests to the index.html file too. |
Nginx serves .php files as downloads, instead of executing them | I am installing a website in a droplet (Digital Ocean). I have an issue for install NGINX with PHP properly. I did a tutorialhttps://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04but when I try to run some .php files it's just downloading it...
for example...htt... | Try this:Edit/etc/nginx/sites-available/defaultUncomment both listen lines to make Nginx listen on port 80 IPv4 and IPv6.listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6Leaveserver_namealone# Make site accessible (...)
server_name localh... |
How do I prevent a Gateway Timeout with FastCGI on Nginx | I am running Django, FastCGI, and Nginx. I am creating an api of sorts that where someone can send some data via XML which I will process and then return some status codes for each node that was sent over.The problem is that Nginx will throw a 504 Gateway Time-out if I take too long to process the XML -- I think longe... | Proxy timeouts are well, for proxies, not for FastCGI...The directives that affect FastCGI timeouts areclient_header_timeout,client_body_timeoutandsend_timeout.Edit: Considering what's found on nginx wiki, thesend_timeout directiveis responsible for setting general timeout of response (which was bit misleading). For Fa... |
How can I tell if my server is serving GZipped content? | I have a webapp on a NGinx server. I setgzip onin the conf file and now I'm trying to see if it works. YSlow says it's not, but 5 out of 6 websites that do the test say it is. How can I get a definite answer on this and why is there a difference in the results? | It looks like one possible answer is, unsurprisingly,curl:$ curl http://example.com/ --silent --write-out "%{size_download}\n" --output /dev/null
31032
$ curl http://example.com/ --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null
2553In the second case the client tells the s... |
How to run Nginx within a Docker container without halting? | I have Nginx installed on a Docker container, and am trying to run it like this:docker run -i -t -p 80:80 mydockerimage /usr/sbin/nginxThe problem is that the way Nginx works, is that the initial process immediately spawns a master Nginx process and some workers, and then quits. Since Docker is only watching the PID of... | nginx, like all well-behaved programs, can be configured not to self-daemonize.Use thedaemon offconfiguration directive described inhttp://wiki.nginx.org/CoreModule. |
Increasing client_max_body_size in Nginx conf on AWS Elastic Beanstalk | I'm running into"413 Request Entity Too Large"errors when posting files larger than 10MB to our API running on AWS Elastic Beanstalk.I've done quite a bit of research and believe that I need to up theclient_max_body_sizefor Nginx, however I cannot seem to find any documentation on how to do this using Elastic Beanstalk... | There are two methods you can take for this. Unfortunately some work for some EB application types and some work for others.Supported/recommended in AWS documentationFor some application types, likeJava SE,Go,Node.js, and maybe Ruby (it's not documented for Ruby, but all the other Nginx platforms seem to support this)... |
NGINX to reverse proxy websockets AND enable SSL (wss://)? | I'm so lost and new to building NGINX on my own but I want to be able to enable secure websockets without having an additional layer.I don't want to enable SSL on the websocket server itself but instead I want to use NGINX to add an SSL layer to the whole thing.Every web page out there says I can't do it, but I know I ... | Just to note that nginx has now support for Websockets on the release 1.3.13. Example of use:location /websocket/ {
proxy_pass http://backend_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}You can also check ... |
Nginx: stat() failed (13: permission denied) | I am using the default config while adding the specific directory with nginx installed on my ubuntu 12.04 machine.server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
index index.html index.htm;
# Make sit... | Nginx operates within the directory, so if you can'tcdto that directory from the nginx user then it will fail (as does thestatcommand in your log). Make sure thewww-usercancdall the way to the/username/test/static. You can confirm that thestatwill fail or succeed by runningsudo -u www-data stat /username/test/staticIn ... |
Locate the nginx.conf file my nginx is actually using | Working on a client's server where there are two different versions of nginx installed. I think one of them was installed with the brew package manager (its an osx box) and the other seems to have been compiled and installed with the nginx packaged Makefile. I searched for all of the nginx.conf files on the server, but... | Runningnginx -tthrough your commandline will issue out a test and append the output with the filepath to the configuration file (with either an error or success message). |
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size | I'm in the process of setting up a new server. The web server of my choice is NGINX. I want to add the domain (e.g.example.com) as a virtual host. I already have two other domains in there and it works fine, but when I try to add the above mentioned domain and start the server it gives me:Job failed. See system journal... | This is most likely happening because of the long domain name. You can fix this by addingserver_names_hash_bucket_size 64;at the top of yourhttpblock (probably located in/etc/nginx/nginx.conf). I quote from the nginx documentation what to do when this error appears:In this case, the directive value should be increased... |
How to edit nginx.conf to increase file size upload | I want to increase themaximum file sizethat can be uploaded.After doing some research online, I found that you have to edit the file 'nginx.conf'.The only way I can currently access this file is by going through Putty and typing in the command:vi /etc/nginx/nginx.confThis will open the file but I have 2 questions now:H... | Addclient_max_body_sizeNow that you are editing the file you need to add the line into the server block, like so;server {
client_max_body_size 8M;
//other lines...
}If you are hosting multiple sites add it to the http context like so;http {
client_max_body_size 8M;
//other lines...
}And also update th... |
nginx: send all requests to a single html page | Using nginx, I want to preserve the url, but actually load the same page no matter what. I will use the url withHistory.getState()to route the requests in my javascript app. It seems like it should be a simple thing to do?location / {
rewrite (.*) base.html break;
}works, but redirects the url? I still need the ... | I think this will do it for you:location / {
try_files /base.html =404;
} |
How can query string parameters be forwarded through a proxy_pass with nginx? | upstream apache {
server 127.0.0.1:8080;
}
server{
location ~* ^/service/(.*)$ {
proxy_pass http://apache/$1;
proxy_redirect off;
}
}The above snippet will redirect requests where the url includes the string "service" to another server, but it does not include query parameters. | From theproxy_passdocumentation:A special case is using variables in the proxy_pass statement: The requested URL is not used and you are fully responsible to construct the target URL yourself.Since you're using $1 in the target, nginx relies on you to tell it exactly what to pass. You can fix this in two ways. First,... |
nginx showing blank PHP pages | I have setup an nginx server with php5-fpm. When I try to load the site I get a blank page with no errors. Html pages are served fine but not php. I tried turning on display_errors in php.ini but no luck. php5-fpm.log is not producing any errors and neither is nginx.nginx.confserver {
listen 80;
root /home... | For reference, I am attaching mylocationblock for catching files with the.phpextension:location ~ \.php$ {
include /path/to/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}Double-check the/path/to/fastcgi_params, ... |
nginx error "conflicting server name" ignored [closed] | Closed.This question isoff-topic. It is not currently accepting answers.Want to improve this question?Update the questionso it'son-topicfor Stack Overflow.Closed11 years ago.Improve this questionserver {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ##... | I assume that you're running a Linux, and you're using gEdit to edit your files. In the/etc/nginx/sites-enabled, it may have left a temp file e.g.default~(watch the~).Depending on your editor, the file could be named.saveor something like it. Just run$ ls -lahto see which files are unintended to be there and remove the... |
SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch | I'm not able to setup SSL. I've Googled and I found a few solutions but none of them worked for me. I need some help please...Here's the error I get when I attempt to restart nginx:root@s17925268:~# service nginx restart
Restarting nginx: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/conf.d/ssl/ssl.key") faile... | I got a MD5 hash with different results for both key and certificate.This says it all. You have a mismatch between your key and certificate.The modulus should match. Make sure you have correct key. |
Default nginx client_max_body_size | I have been getting the nginx error:413 Request Entity Too LargeI have been able to update myclient_max_body_sizein the server section of my nginx.conf file to 20M and this has fixed the issue. However, what is the default nginxclient_max_body_size? | The default value forclient_max_body_sizedirective is1 MiB.It can be set inhttp,serverandlocationcontext — as in themost cases,
thisdirective in a nested block takes precedence over the same directive in the ancestors blocks.Excerpt from thengx_http_core_module documentation:Syntax: client_max_body_size size;
Defaul... |
nginx server_name wildcard or catch-all | I have an instance of nginx running which serves several websites. The first is a status message on the server's IP address. The second is an admin console onadmin.domain.com. These work great. Now I'd like all other domain requests to go to a singleindex.php- I have loads of domains and subdomains and it's impractical... | Change listen option to this in your catch-all server block. (Adddefault_server) this will take all your non-defined connections (on the specified port).listen 80 default_server;if you want to push everything to index.php if the file or folder does not exist;try_files $uri /$uri /index.php;... |
API gateway vs. reverse proxy | In order to deal with the microservice architecture, it's often used alongside a Reverse Proxy (such as nginx or apache httpd) and for cross cutting concerns implementationAPI gateway pattern is used. Sometimes Reverse proxy does the work of API gateway.It will be good to see clear differences between these two approac... | It is easier to think about them if you realize they aren't mutually exclusive. Think of an API gateway as a specific type reverse proxy implementation.In regards to your questions, it is not uncommon to see both used in conjunction where the API gateway is treated as an application tier that sits behind a reverse prox... |
How do you change the server header returned by nginx? | There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header? | Like Apache, this is a quick edit to the source and recompile. FromCalomel.org:The Server: string is the header which
is sent back to the client to tell
them what type of http server you are
running and possibly what version.
This string is used by places like
Alexia and Netcraft to collect
statistics about... |
Are you trying to mount a directory onto a file (or vice-versa)? | I have a docker with version17.06.0-ce. When I trying to install NGINX using docker with command:docker run -p 80:80 -p 8080:8080 --name nginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx:latestIt shows thatdocker: Error response from daemon: oci runtime error:
contain... | Because docker will recognize$PWD/conf/nginx.confas afolderand not as a file. Check whether the$PWD/conf/directory containsnginx.confas adirectory.Test with> cat $PWD/conf/nginx.conf
cat: nginx.conf/: Is a directoryOtherwise, open aDocker issue.It's working fine for me with same configuration. |
duplicate MIME type "text/html"? | I have this in Nginx configuration filesgzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;but Nginx give error when starting up[warn]: duplicate MIME type "text/html" in /etc/nginx/nginx.conf:25What is actually duplicate totex... | For the optiongzip_types, the mime-typetext/htmlis always included by default, so you don't need to specify it explicitly. |
How to redirect a URL in Nginx | I need to redirect everyhttp://test.comrequest tohttp://www.test.com. How can this be done.In the server block I tried addingrewrite ^/(.*) http://www.test.com/$1 permanent;but in browser it saysThe page isn't redirecting properlyFirefox has detected that the server is redirecting the request for this address in a way ... | Best way to do what you want is to add another server block:server {
#implemented by default, change if you need different ip or port
#listen *:80 | *:8000;
server_name test.com;
return 301 $scheme://www.test.com$request_uri;
}And edit your main server block server_name variable as follo... |
Docker Networking - nginx: [emerg] host not found in upstream | I have recently started migrating to Docker 1.9 and Docker-Compose 1.5's networking features to replace using links.So far with links there were no problems with nginx connecting to my php5-fpm fastcgi server located in a different server in one group via docker-compose. Newly though when I rundocker-compose --x-networ... | There is a possibility to use "volumes_from" as a workaround until depends_on feature (discussed below) is introduced. All you have to do is change your docker-compose file as below:nginx:
image: nginx
ports:
- "42080:80"
volumes:
- ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
vo... |
nginx- duplicate default server error | In my error log i get[emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4on Line 4 I have:server_name mysite.com www.mysite.com;Any suggestions? | You likely have other files (such as thedefaultconfiguration) located in/etc/nginx/sites-enabledthat needs to be removed.This issue is caused by a repeat of thedefault_serverparameter supplied to one or morelistendirectives in your files. You'll likely find this conflicting directive reads something similar to:listen ... |
nginx the "ssl" directive is deprecated, use the "listen ... ssl" | After NGINX upgrade tov1.15.2starts getting the warning.nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/etc/nginx/sites-enabled/confid-file-name:8Where the 8th line isssl on;how I can solve this? | Edit yourlistenstatement from:listen 443;tolisten 443 ssl;and comment out or delete :# ssl on;then checknginx -tagain. |
Dealing with nginx 400 "The plain HTTP request was sent to HTTPS port" error | I'm running a Sinatra app behind passenger/nginx. I'm trying to get it to respond to both http and https calls. The problem is, when both are defined in the server block https calls are responded to normally but http yields a 400 "The plain HTTP request was sent to HTTPS port" error. This is for a static page so I'm gu... | I ran into a similar problem. It works on one server and does not on another server with same Nginx configuration. Found the the solution which is answered by Igor herehttp://forum.nginx.org/read.php?2,1612,1627#msg-1627Yes. Or you may combine SSL/non-SSL servers in one server:server {
listen 80;
listen 443 defau... |
How to correctly link php-fpm and Nginx Docker containers? | I am trying to link 2 separate containers:nginx:latestphp:fpmThe problem is that php scripts do not work. Perhaps the php-fpm configuration is incorrect.
Here is the source code, which is in myrepository. Here is the filedocker-compose.yml:nginx:
build: .
ports:
- "80:80"
- "443:443"
volumes... | Don't hardcode ip of containers in nginx config, docker link adds the hostname of the linked machine to the hosts file of the container and you should be able to ping by hostname.EDIT: Docker 1.9 Networking no longer requires you to link containers, when multiple containers are connected to the same network, their host... |
Why does Unicorn need to be deployed together with Nginx? | I would like to know the difference between Nginx and Unicorn. As far as I understand, Nginx is a web server while Unicorn is a Ruby HTTP server.Since both Nginx and Unicorn can handle HTTP requests, what is the need to use the combination of Nginx and Unicorn for RoR applications? | NginxUnicornRefer tounicorn on githubfor more information. |
Nginx Different Domains on Same IP | I would like to host 2 different domains in the same server using Nginx.
I redirected both domains to this host via @ property. Although I configure 2 different server blocks, whenever I try to access second domain, it redirects to first one.Here is my config.server {
listen `www.domain1.example:80`;
acces... | Your "listen" directives are wrong. See this page:http://nginx.org/en/docs/http/server_names.html.They should beserver {
listen 80;
server_name www.domain1.example;
root /var/www/domain1;
}
server {
listen 80;
server_name www.domain2.example;
root /var/www/domain2;
}Note, I have only... |
Upstream / downstream terminology used backwards? (E.g. nginx) | I've always thought of upstream and downstream along the lines of an actual stream, where the flow of information is like water. So upstream is where water/data comes from (e.g. an HTTP request) and downstream is where it goes (e.g. the underlying system that services the request).I've been looking at API gateways rece... | In HTTP world, the "upstream server" term was introduced in the HTTP/1.0 specification,RFC 1945:502 Bad GatewayThe server, while acting as a gateway or proxy, received an invalid
response fromthe upstream serverit accessed in attempting to
fulfill the request.Formal definition was added later, inRFC 2616:upstream/downs... |
What is the point of uWSGI? | I'm looking at theWSGI specificationand I'm trying to figure out how servers likeuWSGIfit into the picture. I understand the point of the WSGI spec is to separate web servers like nginx from web applications like something you'd write usingFlask. What I don't understand is what uWSGI is for. Why can't nginx directly ca... | Okay, I think I get this now.Why can't nginx directly call my Flask application?Becausenginxdoesn't support the WSGI spec. Technically nginx could implement theWSGIspec if they wanted, they just haven't.That being the case, we need a web server that does implement the spec, which is what theuWSGIserver is for.Note that... |
How do I restart nginx only after the configuration test was successful on Ubuntu? | When I restart the nginx service on a command line on an Ubuntu server, the service crashes when a nginx configuration file has errors. On a multi-site server this puts down all the sites, even the ones without configuration errors.To prevent this, I run the nginx configuration test first:nginx -tAfter the test ran suc... | Actually, as far as I know, nginx would show an empty message and it wouldn't actually restart if the configuration is bad.The only way to screw it up is by doing an nginx stop and then start again. It would succeed to stop, but fail to start. |
How to add a response header on nginx when using proxy_pass? | I want to add a custom header for the response received from the server behind nginx.Whileadd_headerworks for nginx-processed responses, it does nothing when theproxy_passis used. | There is a module calledHttpHeadersMoreModulethat gives you more control over headers. It does not come with Nginx and requires additional installation. With it, you can do something like this:location ... {
more_set_headers "Server: my_server";
}That will "set the Server output header to the custom value for any sta... |
How to verify if nginx is running or not? | Afterrunning an ASP.NET vNext projecton my local machine I was trying to figure out how I can run it onnginxas it looks to be arecommended choiceFollowingjsinh'sblog, I installed it using:sudo apt-get update
sudo apt-get install nginx -yI was trying to understand whether it is working or not by using:ifconfig eth0 | gr... | Looking at the requirement you have, the below command shallhelp:service nginx status |
Terminal error: zsh: permission denied: ./startup.sh | I am running a command./startup.sh nginx:startand I am getting this error messagezsh: permission denied: ./startup.shwhy could this be happening? | Be sure to give it the execution permission.cd ~/the/script/folder
chmod +x ./startup.shThis will give exec permission to user, group and other, so beware of possible security issues. To restrict permission to a single access class, you can use:chmod u+x ./startup.shThis will grant exec permission only to userFor refe... |
How to redirect single URL in Nginx? | I'm in the process of reorganizing URL structure.
I need to setup redirect rules for specific URLs - I'm using Nginx.Basically Something like this:http://example.com/issue1 --> http://example.com/shop/issues/custom_issue_name1
http://example.com/issue2 --> http://example.com/shop/issues/custom_issue_name2
http://exampl... | Put this in your server directive:location /issue {
rewrite ^/issue(.*) http://$server_name/shop/issues/custom_issue_name$1 permanent;
}Or duplicate it:location /issue1 {
rewrite ^/.* http://$server_name/shop/issues/custom_issue_name1 permanent;
}
location /issue2 {
rewrite ^.* http://$server_name/shop/issues... |
Redirecting EC2 Elastic Load Balancer from HTTP to HTTPS | I want to redirect all the HTTP request to https request onELB. I have two EC2 instances. I am using nginx for the server. I have tried a rewriting the nginx conf files without any success. I would love some advice on it. | AWS Application Load Balancers now support native HTTP to HTTPS redirect.To enable this in the console, do the the following:Go to your Load Balancer in EC2 and tab "Listeners"Select "View/edit rules" on your HTTP listenerDelete all rules except for the default one (bottom)Edit default rule: choose "Redirect to" as an ... |
How to configure nginx to enable kinda 'file browser' mode? | Once I've seen this before when I type a URLhttp://test.com/test/, instead of give me a html page, it gives me a 'file browser' like interface to browse all the files in the given location.I think it maybe a nginx module that could be enable in the location context.Thenginx.conffile:worker_processes 1;
events {
wo... | You should tryngx_http_autoindex_module.Setautoindexoption toon. It isoffby default.Your example configuration should be oklocation /{
root /home/yozloy/html/;
index index.html;
autoindex on;
}Withoutautoindexoption you should be getting Error 403 for requests that end with/on directories that do not have a... |
nginx upload client_max_body_size issue | I'm running nginx/ruby-on-rails and I have a simple multipart form to upload files.
Everything works fine until I decide to restrict the maximum size of files I want uploaded.
To do that, I set the nginxclient_max_body_sizeto1m(1MB) and expect a HTTP 413 (Request Entity Too Large) status in response when that rule bre... | nginx "fails fast" when the client informs it that it's going to send a body larger than theclient_max_body_sizeby sending a 413 response and closing the connection.Most clients don't read responses until the entire request body is sent. Because nginx closes the connection, the client sends data to the closed socket, ... |
How do I rewrite URLs in a proxy response in NGINX | I'm used to using Apache with mod_proxy_html, and am trying to achieve something similar with NGINX. The specific use case is that I have an admin UI running in Tomcat on port 8080 on a server at the root context:http://localhost:8080/I need to surface this on port 80, but I have other contexts on the NGINX server run... | We should first readthe documentation on proxy_passcarefully and fully.The URI passed to upstream server is determined based on whether "proxy_pass" directive is used with URI or not. Trailing slash in proxy_pass directive means that URI is present and equal to/. Absense of trailing slash means hat URI is absent.Proxy_... |
EventSource / Server-Sent Events through Nginx | On server-side using Sinatra with astreamblock.get '/stream', :provides => 'text/event-stream' do
stream :keep_open do |out|
connections << out
out.callback { connections.delete(out) }
end
endOn client side:var es = new EventSource('/stream');
es.onmessage = function(e) { $('#chat').append(e.data + "\n") };... | Your Nginx config is correct, you just miss few lines.Here is a "magic trio" makingEventSourceworking through Nginx:proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;Place them intolocationsection and it should work.You may also need to addproxy_buffering off;
proxy_cache off;That's ... |
Tuning nginx worker_process to obtain 100k hits per min | We have a server that is serving one html file.Right now the server has 2 CPUs and 2GB of ram. From blitz.io, we are getting about 12k connections per minute and anywhere from 200 timeouts in that 60 seconds with 250 concurrent connections each second.worker_processes 2;
events {
worker_connections 1024;
}If I incre... | Config file:worker_processes 4; # 2 * Number of CPUs
events {
worker_connections 19000; # It's the key to high performance - have a lot of connections available
}
worker_rlimit_nofile 20000; # Each connection needs a filehandle (or 2 if you are proxying)
# Total amount of users you can serve = worker_pr... |
"configuration file /etc/nginx/nginx.conf test failed": How do I know why this happened? | I'm an nginx noob trying out thisthistutorial on nginx 1.1.19 on ubuntu 12.04. I havethisnginx config file.When I run this command the test fails:$ sudo service nginx restart
Restarting nginx: nginx: [crit] pread() "/etc/nginx/sites-enabled/csv" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.con... | sudo nginx -tshould test all files and return errors and warnings locations |
nginx - read custom header from upstream server | I am using nginx as a reverse proxy and trying to read a custom header from the response of an upstream server (Apache) without success. The Apache response is the following:HTTP/1.0 200 OK
Date: Fri, 14 Sep 2012 20:18:29 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.10
Connection: close
Content-... | It's not only possible, it's easy:in nginx the response header values are available through a variable (one per header).
Seehttp://wiki.nginx.org/HttpCoreModule#.24sent_http_HEADERfor the details on those variables.In your examle the variable would be $sent_http_My_custom_header. |
How to preserve request url with nginx proxy_pass | I was trying to useThinapp server and had one issue.When nginxproxiesthe request to Thin (or Unicorn) usingproxy_pass http://my_app_upstream;the application receives the modified URL sent by nginx (http://my_app_upstream).What I want is to pass the original URL and the original request from client with no modification ... | I think theproxy_set_headerdirective could help:location / {
proxy_pass http://my_app_upstream;
proxy_set_header Host $host;
# ...
} |
Nginx serve static file and got 403 forbidden | Just want to help somebody out. yes ,you just want to serve static file using nginx, and you got everything right innginx.conf:location /static {
autoindex on;
#root /root/downloads/boxes/;
alias /root/downloads/boxes/;
}But , in the end , you failed. You got "403 forbidden" from browser...--... | You should give nginx permissions to read the file. That means you should give the user that runs the nginx process permissions to read the file.This user that runs the nginx process is configurable with theuserdirective in the nginx config, usually located somewhere on the top ofnginx.conf:user www-datahttp://wiki.ngi... |
Angular app has to clear cache after new deployment | We have an Angular 6 application. It’s served on Nginx. And SSL is on.When we deploy new codes, most of new features work fine but not for some changes. For example, if the front-end developers update the service connection and deploy it, users have to open incognito window or clear cache to see the new feature.What ty... | The problem is When a static file gets cached it can be stored for very long periods of time before it ends up expiring. This can be an annoyance in the event that you make an update to a site, however, since the cached version of the file is stored in your visitors’ browsers, they may be unable to see the changes made... |
What does "trust proxy" actually do in express.js, and do I need to use it? | I am writing an express app that sits behind an nginx server. I was reading through express's documentation and it mentioned the 'trust proxy' setting. All it says istrust proxy Enables reverse proxy support, disabled by defaultI read the little article here that explains Secure Sessions in Node with nginx.http://blog... | This is explained in detail in theexpress behind the proxies guideBy enabling the "trust proxy" setting via app.enable('trust proxy'), Express will have knowledge that it's sitting behind a proxy and that the X-Forwarded-* header fields may be trusted, which otherwise may be easily spoofed.Enabling this setting has sev... |
dump conf from running nginx process | Is it possible to get which conf the nginx is using only from a running nginx process?To get the conf file path. sometimesps auxreveal it, sometimes it doesn't. It might be just something likenginx: master process /usr/sbin/nginx(same as/proc/PID/cmdline)So isnginx -Vthe only solution?Fromthis question, is it possible ... | As of Nginx 1.9.2 you can dump the Nginx config with the-Tflag:-T— same as-t, but additionally dump configuration files to standard output (1.9.2).Source:http://nginx.org/en/docs/switches.htmlThis is not the same as dumping for a specific process. If your Nginx is using a different config file, check the output forps a... |
Why do HTTP servers forbid underscores in HTTP header names | I had a problem with a custom HTTPSESSION_IDheader not being transfered by nginx proxy.I was told that underscores are prohibited according to the HTTP RFC.Searching, I found that most servers likeApacheornginxdefine them as illegal inRFC2616section 4.2, which says:follow the same generic format as that given in Sectio... | They are not forbidden, it's CGI legacy. See "Missing (disappearing) HTTP Headers".If you do not explicitly setunderscores_in_headers on;, nginx will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers ... |
What are the benefits of using Nginx in front of a webserver for Go? | I am writing some webservices returning JSON data, which have lots of users.What are the benefits of using Nginx in front my server compared to just using the go http server? | It depends.Out of the box, putting nginx in front as a reverse proxy is going to give you:Access logsError logsEasy SSL terminationSPDY supportgzip supportEasy ways to set HTTP headers for certain routes in a couple of linesVery fast static asset serving (if you're serving off S3/etc. though, this isn't that relevant)T... |
Docker Network Nginx Resolver | I am trying to get rid of deprecated Docker links in my configuration. What's left is getting rid of thoseBad Gatewaynginx reverse proxy errors when I recreated a container.Note: I am using Docker networks in bridge mode. (docker network create nettest)I am using the following configuration snippet inside nginx:locatio... | First off, you should be using the Docker embedded DNS server at127.0.0.11.Your problem could be caused by 1 of the following:nginx is trying to use IPv6 (AAAA record) for the DNS queries.Seehttps://stackoverflow.com/a/35516395/1529493for the solution.Basically something like:http {
resolver 127.0.0.11 ipv6=off;
}T... |
Use nginx to serve static files from subdirectories of a given directory | I have several sets of static.htmlfiles on my server, and I would like use nginx to serve them directly. For example, nginx should serve an URI of the following pattern:www.mysite.com/public/doc/foo/bar.htmlwith the.htmlfile that is located at/home/www-data/mysite/public/doc/foo/bar.html. You can think offooas the set ... | It should work, howeverhttp://nginx.org/en/docs/http/ngx_http_core_module.html#aliassays:When location matches the last part of the directive’s value:
it is better to use the root directive instead:which would yield:server {
listen 8080;
server_name www.mysite.com mysite.com;
error_log /home/www-... |
Nginx will not start (Address already in use) | I have a problem with nginx. I tried different solutions, but for me nothing work.
That is my error:4 root@BANANAS ~ # sudo service nginx restart :(
Restarting nginx: nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Addres... | Probably other process is using specified port:sudo netstat -tulpnGet the PID of the process that already using 443. And send signal with kill command.sudo kill -2
sudo service nginx restartAternatively you can do:sudo fuser -k 443/tcpMake sure you dont use old syntax:server {
listen :80;
listen [::]:80;
}The... |
What language are nginx conf files? | I want to write some more complex conditions in my Nginx configuration files but I'm not sure of the syntax and can't find docs describing what you can do beyond the basics in the examples and I can't seem to find this on the Nginx forums or on the mailing list.For example, is it possible for me to have anunlessconditi... | So I'm a newbie to nginx, and had this same question. Turns out the syntax of the language as mentioned above is both custom and actually quite simple. The syntax iscaptured in a sectionin the NGINX docs, and repeated here for convenience:nginx consists of modules which are controlled by directives
specified in the c... |
node.js itself or nginx frontend for serving static files? | Is there any benchmark or comparison which is faster: place nginx in front of node and let it serve static files directly or use just node and serve static files using it?nginx solution seems to be more manageable for me, any thoughts? | I'll have to disagree with the answers here. While Node will do fine, nginx will most definitely be faster when configured correctly. nginx is implemented efficiently in C following a similar pattern (returning to a connection only when needed) with a tiny memory footprint. Moreover, it supports thesendfilesyscall to s... |
GD Library extension not available with this PHP installation Ubuntu Nginx | I am usingLaravelweb framework on myubuntu 14.04server andNginxweb server, I have this error when I try to upload a file usingLaravelto the server.
my upload directory is on thepublic/uploadsfolder that has 777 permission. | The GD Graphics Library is for dynamically manipulating images.
For Ubuntu you should install it manually:PHP8.0:sudo apt-get install php8.0-gdPHP8.1:sudo apt-get install php8.1-gdPHP8.2:sudo apt-get install php8.2-gdPHP8.3:sudo apt-get install php8.3-gdThat's all, you can verify that GD support loaded:php -i | grep -i... |
How to serve all existing static files directly with NGINX, but proxy the rest to a backend server. | location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if (-f $request_filename) {
access_log off;
expires 30d;
break;
}
if (!-f $request_filename) {
proxy_pass http://... | Usetry_filesand named location block ('@apachesite'). This will remove unnecessary regex match and if block. More efficient.location / {
root /path/to/root/of/static/files;
try_files $uri $uri/ @apachesite;
expires max;
access_log off;
}
location @apachesite {
proxy_set_header X-Real-IP $remote_a... |
How to set the allowed url length for a nginx request (error code: 414, uri too large) | I am using Nginx in front of 10 mongrels.When I make a request with size larger then 2900 I get back an:error code 414: uri too largeDoes anyone know the setting in the nginx configuration file which determines the allowed uri length ? | From:http://nginx.org/r/large_client_header_buffersSyntax:large_client_header_buffersnumbersize;Default:large_client_header_buffers 4 8k;Context:http, serverSets the maximumnumberandsizeof buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI ... |
react.js application showing 404 not found in nginx server | I uploaded react.js application to a server. I'm using nginx server. Application is working fine. But when I go to another page & refresh, the site is not working. It's showing a 404 Not found error.How can I solve this? | When yourreact.jsapp loads, the routes are handled on the frontend by thereact-router. Say for example you are athttp://a.com. Then on the page you navigate tohttp://a.com/b. This route change is handled in the browser itself. Now when you refresh or open the urlhttp://a.com/bin the a new tab, the request goes to yourn... |
Docker: Temporary failure resolving 'deb.debian.org' | I have a Rails application that I want to deploy using Docker on an Ubuntu server. I have the Dockerfile for the application already set up, right now I want to view thenginxconf in its container.I ran the command below to start annginxcontainer in an interactive mode:docker run -i -t nginx:latest /bin/bashRight now I ... | Here's how I solved it:Start the docker container for the application in an interactive mode, in my case it annginxcontainer :docker run -i -t nginx:latest /bin/bashRun the command below to grantreadpermission to theothersrole for theresolv.conffile:chmod o+r /etc/resolv.confNote: If you are having this issue on your h... |
Nginx variables similar to SetEnv in Apache? | I use SetEnv in Apache to set some variables in virtualhosts that I recover in PHP using$_SERVER[the_variable].Now I am switching to Perl Catalyst and Nginx, but it seems that the "env" directive in Nginx is not the same. It does not work. How can it be accomplished?Here is the background picture, just in case someone ... | NGINX doesn't manage your backend processes like apache does, so it can't affect their environments. To set a new$_SERVERPHP variable from NGINX, you need to add a newfastcgi_paramentry along with the rest of them. Wherever you're includingfastcgi_paramsorfastcgi.conf. |
nginx: connect() failed (111: Connection refused) while connecting to upstream | Trying to deploy my first portal .I am getting 502 gateway timeout error in browser when i was sending the request through browserwhen i checked the logs , i got this error2014/02/03 09:00:32 [error] 16607#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 14.159.131.19, server: foo.... | I don't think that solution would work anyways because you will see some error message in your error log file.The solution was a lot easier than what I thought.simply, open the following path to your php5-fpmsudo nano /etc/php5/fpm/pool.d/www.confor if you're the admin 'root'nano /etc/php5/fpm/pool.d/www.confThen find ... |
What regular expression engine does Nginx use? | What regular expression engine does Nginx use?There are a lot of possibilities.More to the point, what flavor of syntax does it support, that is, what syntax features can I make use of? | Nginx uses thePCRE library. Thecompile-time options listhas some notes on this. |
Forward request headers from nginx proxy server | I'm using Nginx as a proxy to filter requests to my application. With the help of the "http_geoip_module" I'm creating a country code http-header, and I want to pass it as a request header using "headers-more-nginx-module". This is the location block in the Nginx configuration:location / {
proxy_pass ... | If you want to pass the variable to your proxy backend, you have to set it with the proxy module.location / {
proxy_pass http://example.com;
proxy_set_header Host example.com;
proxy_set_header HTTP_Country-Code $geoip_country_code;
proxy_pass_request_he... |
nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1 | I'm new to NGINX and I'm trying to setup minimal working thing. So I trying to run aiohttp mini-app with nginx and supervisor (bythisexample). But I can't configure Nginx right and getting the following error:nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1Here is full default.c... | I am assuming that you havehttpin your /etc/nginx/nginx.conf file which then tells nginx toinclude sites-enabled/*;So then you havehttp
http
serverAs the http directive should only happen once just remove the http directive from your sites-enabled config file(s) |
NGINX gzip not compressing JavaScript files | All JavaScript files are not compressed by nginx gzip.CSS files are working.In mynginx.confI have the following lines:gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_types text/plain application/x-javascript text/xml text/css;
gzip_vary on; | Change this line:gzip_types text/plain application/x-javascript text/xml text/css;To be this:gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;Note the addition ofapplication/javascriptandtext/javascriptto your list of gzip types.There are also more details—an... |
What is the difference between nginx daemon on/off option? | This is my first web-server administration experience and I want to build docker container which uses nginx as a web-server. In all docker tutorialdaemon off;option is put into main.conffile but explanation about it is omitted.I search on the internet about it and I don't understand what is the difference betweendaemon... | For normal production (on a server), use the defaultdaemon on;directive so the Nginx server will start in the background. In this way Nginx and other services are running and talking to each other. One server runs many services.ForDocker containers(or for debugging), thedaemon off;directive tells Nginx to stay in the f... |
How to run a shell script on every request? | I want to run a shell script every time my nginx server receives any HTTP request. Any simple ways to do this? | You can execute a shell script viaLuacode from the nginx.conf file to achieve this. You need to have theHttpLuaModuleto be able to do this.Here's an example to do this.location /my-website {
content_by_lua_block {
os.execute("/bin/myShellScript.sh")
}
} |
Is GridFS fast and reliable enough for production? | I develop a new website and I want to use GridFS as storage for all user uploads, because it offers a lot of advantages compared to a normal filesystem storage.Benchmarks with GridFS served by nginx indicate, that it's not as fast as a normal filesystem served by nginx.Benchmark with nginxIs anyone out there, who uses ... | I use gridfs at work on one of our servers which is part of a price-comparing website with honorable traffic stats (arround 25k visitors per day). The server hasn't much ram, 2gigs, and even the cpu isn't really fast (Core 2 duo 1.8Ghz) but the server has plenty storage space : 10Tb (sata) in raid 0 configuration. The ... |
nginx - two subdomain configuration | I'm new to Nginx and I'm trying to get subdomains working.What I would like to do is take my domain (let's call itexample.com) and add:sub1.example.com,sub2.example.com, and also havewww.example.comavailable.I know how to do this with Apache, but Nginx is being a real head scratcher.I'm running Debian 6.My current /etc... | The mistake is putting a server block inside a server block, you should close the main server block then open a new one for the sub domainsserver {
server_name example.com;
# the rest of the config
}
server {
server_name sub1.example.com;
# sub1 config
}
server {
server_name sub2.example.com;
# ... |
nginx proxy_pass 404 error, don't understand why | I am trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as expected. Does anyone know why?upstream backend{
server localhost:8080;
}
server {
location /api {
proxy_pass http://backend;
}
location / {
r... | Thislocation /api {
proxy_pass http://backend;
}Needs to be thislocation /api/ {
proxy_pass http://backend/;
} |
NGINX $request_uri vs $uri | How do you determine when to use$request_urivs$uri?According to NGINX documentation,$request_uriis the original request (for example,/foo/bar.php?arg=bazincludes arguments and can't be modified) but$urirefers to the altered URI.If the URI doesn't change, does $uri = $request_uri?Would it be incorrect or better or worse... | $uriis not equivalent to$request_uri.The$urivariable is set to the URI thatnginxiscurrently processing- but it is also subject to normalisation, including:Removal of the?and query stringConsecutive/characters are replace by a single/URL encoded characters are decodedThe value of$request_uriis always the original URI an... |
Full record url in nginx log | We use following nginx site configure file in our production env.log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $request_time';
server {
root /srv/www/web;
server_name *.t... | Try adding the$hostvariable in log_format:log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$host" "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $request_time';http://wiki.nginx.org/HttpCoreModule#.24host:$hostThis variable is equal to line Host ... |
Proxying to another web service with Flask | I want to proxy requests made to my Flask app to another web service running locally on the machine. I'd rather use Flask for this than our higher-level nginx instance so that we can reuse our existing authentication system built into our app. The more we can keep this "single sign on" the better.Is there an existing... | I have an implementation of a proxy using httplib in a Werkzeug-based app (as in your case, I needed to use the webapp's authentication and authorization).Although the Flask docs don't state how to access the HTTP headers, you can userequest.headers(seeWerkzeug documentation). If you don't need to modify the response, ... |
Nginx: Reject request if header is not present or wrong | If I have the headers: X_HEADER1 & X_HEADER2, I want to reject all requests if either of these headers are not set or do not contain the correct values. What is the best way to do this?Thanks | You can use two IF statements either before or in the location block to inspect the headers and then return a 403 error code if it is present. Alternatively, you can use those IF statements to rewrite to a specific location block and deny all in that location:if ($http_x_custom_header) {
return 403;
}Reference:http... |
Force nginx to send specific Content-Type | How to overwrite default Content-Type in nginx? Currently when I request 01.dae file, there'sContent-Type: application/octet-stream;And I want it to beContent-Type: application/xml;I tried something likelocation ~* \.dae$ {
types { };
default_type application/xml;
}andlocation ~* \.dae$ {
add_header Content-Type ... | You can edit/etc/nginx/mime.typesand add ittypes {
application/xml dae;
}I haven't found the the exact stringapplication/xmlin mymime.typesso I suppose you can directly include it inside your server block, in the server scope or something.If you do not have access to the systemmime.typesthen you can set it i... |
Nginx subdomain configuration | I have nginx acting as a reverse proxy to apache. I now need to add a new subdomain
that will serve files from another directory, but at the same time I want all location and proxy_pass directives that I have for the default host to apply to the subdomain also.I know that if I copy the rules from the default host to th... | You could move the common parts to another configuration file andincludefrom both server contexts. This should work:server {
listen 80;
server_name server1.example;
...
include /etc/nginx/include.d/your-common-stuff.conf;
}
server {
listen 80;
server_name another-one.example;
...
include /etc/nginx/inc... |
Nginx Invalid PID number | I issued a nginx -s stop and after that I got this error when trying to reload it.[error]: invalid PID number "" in "/var/run/nginx.pid"That /var/run/nginx/pid file is empty atm.What do I need to do to fix it? | nginx -s reload is only used to tell a running nginx process to reload its config. After a stop, you don't have a running nginx process to send a signal to. Just run nginx (possibly with a -c /path/to/config/file) |
multiple websites on nginx & sites-available | With the base install of nginx, yoursites-availablefolder has just one file:defaulthow does thesites-availablefolder work and how would I use it to host multiple (separate) websites? | Just to add another approach, you can use a separate file for each virtual domain or site you're hosting.
You can use a copy of default as a starting point for each one and customize for each site.Then create symlinks in sites-enabled. In this way you can take sites up and down just by adding or removing a symlink and... |
How to log all headers in nginx? | How do I log all the headers the client (browser) has sent in Nginx? I also want to log the response headers. Note that I am using nginx as reverse proxy.After going through documentation, I understand that I can log a specific header, but I want to log all of the headers. | After much research, I can conclude that it is not possible out of the box.Update- you can use openresty which comes with Lua. Using Lua one can do pretty cool things, including logging all of the headers to say, Redis or some other server |
File Not Found when running PHP with Nginx | Recently I installed the latest version of Nginx and looks like I'm having hard time running PHP with it.Here is the configuration file I'm using for the domain:server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php;
}
error_page 500 502 503 504 /50x.h... | Try another *fastcgi_param* something likefastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; |
A better way to restart/reload Gunicorn (via Upstart) after 'git pull'ing my Django projects | Im looking for something better thansudo restart projectnameevery time I issue agit pull origin master, which pulls down my latest changes to a Django project. Thisrestartcommand, I believe, is related to Upstart, which I use to start/top my Gunicorn server process.This restart causes a brief outage. Users hitting the ... | For a graceful reload, you should instead use Upstart'sreloadcommand, e.g.:sudo reload jobnameAccording to the initctl (Upstart)manpage,reloadwill send aHUPsignal to the process:reload JOB [KEY=VALUE]...
Sends the SIGHUP signal to running process of the named JOB instance....which for Gunicorn will trigger a gr... |
Adding and using header (HTTP) in nginx [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, ... | To add a header, add theadd_headerdeclaration to either thelocationblock or theserverblock:server {
add_header X-server-header "my server header content!";
location /specific-location {
add_header X-location-header "my specific-location header content!";
}
}Anadd_headerdeclaration within alocationblock ... |
How can I allow access to a single IP address via Nginx.conf? | Nginx, Passenger, and Rails are running beautifully on my Linode. Before I launch, I'd like to restrict access so only my IP can view the site.I've tried to deny access to all, and allow access to only my IP in Nginx. It does deny access to all, but I can't get the allow to work. I have checked to ensure the IP address... | modify your nginx.confserver {
listen 80;
server_name www.foo.bar;
location / {
root /path/to/rails/public/;
passenger_enabled on;
allow my.public.ip.here;
deny all;
}
} |
Are a WSGI server and HTTP server required to serve a Flask app? | Setting up Flask with uWSGI and Nginx can be difficult. I tried followingthis DigitalOcean tutorialand still had trouble. Even with buildout scripts it takes time, and I need to write instructions to follow next time.If I don't expect a lot of traffic, or the app is private, does it make sense to run it without uWSGI? ... | When you "run Flask" you are actually running Werkzeug's development WSGI server, and passing your Flask app as the WSGI callable.The development server is not intended for use in production. It is not designed to be particularly efficient, stable, or secure. It does not support all the possible features of a HTTP ser... |
Docker Nginx stopped: [emerg] 1#1: host not found in upstream | I am running docker-nginx on ECS server. My nginx service is suddenly stopped because theproxy_passof one of the servers got unreachable. The error is as follows:[emerg] 1#1: host not found in upstream "dev-example.io" in /etc/nginx/conf.d/default.conf:988My config file is as below:server {
listen 80;
... | Include to prevent Nginx from crashing if your site is down, include a resolver directive, as follows:server {
listen 80;
server_name test.com;
location / {
resolver 8.8.8.8;
proxy_pass http://dev-exapmle.io:5016/;
proxy_redir... |
Nginx proxy_pass with $remote_addr | I'm trying to include $remote_addr or $http_remote_addr on my proxy_pass without success.The rewrite rule workslocation ^~ /freegeoip/ {
rewrite ^ http://freegeoip.net/json/$remote_addr last;
}The proxy_pass without the $remote_addr works, but freegeoip does not read the x-Real-IPlocation ^~ /freegeoip/ {
proxy_p... | If the proxy_pass statement has no variables in it, then it will use the "gethostbyaddr" system call during start-up or reload and will cache that value permanently.if there are any variables, such as using either of the following:set $originaddr http://origin.example.com;
proxy_pass $originaddr;
# or even
proxy_pass h... |
Reload Nginx configuration | I am trying to modify the Nginx config file to remove a "rewrite".Currently, I have this config file:worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
li... | Maybe you're not doing it as root?Trysudo nginx -s reload, if it still doesn't work, you might want to trysudo pkill -HUP nginx. |
Why use Mongrel2? | I'm confused what purposeMongrel2serves/provides thatnginxdoesn't already do.(Yes, I've read themanualbut I must to be too much of a noob to understand how it's fundamentally different than nginx)My current web application stack is:-nginx: webserver-Lua: programming language-FastCGI + LuaJIT: to connect nginx to Lua-Po... | If you could only name one thing then it would be thatMongrel2 is build around ZeroMQwhich means that scaling your web server has never been easier.If a request comes in, Mongrel2 receives it (nothing unusual here, same as for NginX and any other httpd). Next thing that happens is that Mongrel2 distributes the task ofc... |
Why does Nginx return a 403 even though all permissions are set properly? | I have Nginx setup and displaying the test page properly. If I try to change the root path, I get a 403 Forbidden error, even though all permissions are identical. Additionally, the nginx user exists.nginx.conf:user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
... | I experienced the same problem and it was due toSELinux.To check if SELinux is running:# getenforceTo disable SELinux until next reboot:# setenforce PermissiveRestart Nginx and see if the problem persists. If you would like to permanently alter the settings you can edit/etc/sysconfig/selinuxIf SELinux is your problem y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.