Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Deploy Create-React-App on Nginx | I'm attempting to deploy mycreate-react-appSPA on a Digital Ocean droplet with Ubuntu 14.04 and Nginx. Per the static serverdeployment instructions, I can get it working when I runserve -s build -p 4000, but the app comes down as soon as I close the terminal. It is not clear to me from thecreate-react-apprepo readme ho... | One of the major benefits of React (and Create React App) is that you don't need the overhead of running a Node server (or proxying to it with Nginx); you can serve the static files directly.From theDeployment documentationyou've linked to, Create React App describes what to do:npm run buildcreates abuilddirectory with... |
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) | WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].I am facing this error on mac while trying to run this commanddocker ru... | Try changing the command asdocker run --rm --gpus all --platform linux/amd64 -v static_volume:/home/app/staticfiles/ -v media_volume:/app/uploaded_videos/ --name=deepfakeapplication abhijitjadhav1998/deefake-detection-20framemodelPlease ensure that you have compatible Nvidia Drivers available as this application uses N... |
413 Request Entity Too Large nginx django | I am making a practice web service (client's artbook display web site) The client can upload artbook images to the server.But I get the following error when the client uploads too many images413 Request Entity Too LargeI tried addingclient_max_body_size 100M;in nginx.conf#user nobody;
#Defines which Linux system user ... | You've fixed the issue on your HTTP server, but your HTTP server is set to 301 redirect to your HTTPS server... your HTTPS server does not haveclient_max_body_sizeconfigured, so it is defaulting to 1M & causing this413 (Request Entity Too Large)error.To fix this issue, you simply need to addclient_max_body_sizetoBOTHth... |
docker-compose yml running a script after up | I want to run a script, right after running`docker-compose up -d`Here is my snippet ofdocker-compose.yml. The other settings are mysql server, redis...etc....but they are not causing any problemsweb:
image: nginx
container_name: web-project
volumes:
- ./code:/srv
working_dir: /srv/myweb
extra_hosts:
... | commandoverrides the default command.That's the reason your container stops: nginx never starts.At the end of your script you have to runnginx#!/bin/bash
echo running post install scripts for web..;
cd /srv/myweb
npm install
composer self-update
composer update
nginxBy the way, I suggest you to change your script and ... |
Rewrite root address to a subdirectory in nginx | I'm converting my mediawiki site to use nginx as a frontend for static files with apache on the backend for php. I've gotten everything working so far except for when I view the root directory "example.com" it tries to serve a directory listing and gives a 403 error since I have that disabled and don't have an index fi... | I found help in the nginx irc chat.Basically what I needed to do was use a return instead of rewrite. So I changed this:location = / {
rewrite "^$" /wiki/Main_Page;
}to this:location = / {
return 301 http://www.example.com/wiki/Main_Page;
} |
curl Failed to connect to localhost port 80 | My host's file maps127.0.0.1tolocalhost.$ curl -I 'localhost'
curl: (7) Failed to connect to localhost port 80: Connection refusedAnd then$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.2.4
Date: Wed, 09 Apr 2014 04:20:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Oct 2012 21:48:34 GMT
C... | Since you have a::1 localhostline in your hosts file, it would seem that curl is attempting to use IPv6 to contact your local web server.Since the web server is not listening on IPv6, the connection fails.You could try to use the--ipv4option tocurl, which should force an IPv4 connection when both are available. |
nginx. Test which location used to process request | I'm wondering how do I know if a particular location[s] used to process request innginx.E.g.:# 1
location / {}
# 2
location ~ /[\w\-]+\.html {}
# 3
location ~ /\w+\.html {}How do I know if URI like/mysiteis processed by 3rd location and not 2nd?
I tend to useadd_headerfor this matter:location / {
add_header locat... | The add_header trick is how I would do it to.I'm at work right now, so I can't test but you might possibly get something in the logfile i you set theerror_loglevel to:debug: you're nginx needs to be built using--with-debugfor this to work, you can check that with thenginx -Vcommandnotice: if debug logging isn't enabled |
Nginx reverse proxy multiple backends | Here is my situation: I will have one frontend server running Nginx, and multiple backends servers running Apache + passenger with different rails applications. I am NOT trying to do any load balancing. What I need to do is setup Nginx to proxy connections to specific servers based on the URL. IE,client.example.comshou... | You can match the different URLs withserver {}blocks, then inside each server block, you'd have the reverse proxy settings.Below, an illustration;server {
server_name client.example.com;
# app1 reverse proxy follow
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwa... |
How to set X-Frame-Options Allow-From in nginx correctly | Im trying to set the ALLOWED-FROM in Nginx but all settings I tried so far resulted in the following Chrome error:Invalid 'X-Frame-Options' header encountered when loading 'https://domain.com/#/register': 'ALLOW-FROM domain.com' is not a recognized directive. The header will be ignored.This options I tried are those: (... | in Chrome and Safari you need to useContent-Security-PolicyContent-Security-Policy: frame-ancestors domain.comYou can check more details on this site:https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives |
How to inject custom content via Nginx? | Is there a way to inject a few lines of script etc. for each served php/html/etc. page?
For example some custom javascript after -tag?I know, you should be able to use lua in nginx but is there a better solution?I am running multiple different web application behind the nginx, so it feels proper way to do this. I don'... | I found the way to do this:http://nginx.org/en/docs/http/ngx_http_sub_module.htmllocation / {
sub_filter
'';
sub_filter_once on;
} |
Nginx does redirect, not proxy | I want to set up Nginx as a reverse proxy for a https service, because we have a special usecase where we need to "un-https" a connection:http://nginx_server:8080/myserver ==> https://mysecureserviceBut what happens is that the actual https service isn't proxied. Nginx does redirect me to the actual service, so the URL... | You have to use theproxy_redirectto handle the redirection.Sets the text that should be changed in the “Location” and “Refresh” header fields of a
proxied server response. Suppose a proxied server returned the header field
“Location:https://myserver/uri/”. The directive
will rewrite this string to “Location: http:... |
Disable caching of a single file with try_files directive | I'm serving Angular 2 application with nginx using location section this way:location / {
try_files $uri $uri/ /index.html =404;
}try_files directive tries to find the requested uri in root directory and if it fails to find one it simply returns index.htmlHow to disable caching of index.html file? | Found a solution using nginx named locations:location = / {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
location / {
gzip_static on;
try_files $uri @index;
}
location @index {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
} |
How to redirect only the root path in nginx? | I only want to redirect the root path from domain A to domain B. For example, if user type inhttps://www.a.com/orhttps://www.a.comorhttp://a.comall redirect tohttps://www.b.com/, but if user type inhttps://www.a.com/something/then it keep there without redirect.I tried the following:location / {
return 301 https://... | I got it.location ~ ^/$ {
return 301 https://www.b.com/;
} |
Nginx rewrite non-www-prefixed domain to www-prefixed domain | I see the NginxHttpRewriteModule documentationhas an example to rewrite a www-prefixed domain to a non-www-prefixed domain:if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
}How can I do the reverse-- rewrite a n... | Well I guess I don't really need the outer "if" statement since I'm only checking for domains of the form xxx.xxx anyways. The following works for me, though it's not robust. Let me know if there is a better solution.if ($host ~* ^([a-z0-9\-]+\.(com|net|org))$) {
set $host_with_www www.$1;
rewrite ^(.*)... |
NGINX caching proxy fails with SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure | NGINX acting as a caching proxy encounters problems when fetching content from CloudFront server over HTTPS:This is the extract from the NGINX's error log:2014/08/14 16:08:26 [error] 27534#0: *11560993 SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) whil... | I had the exactly same problem and spent a couple of hours...
I guess you are using older version of nginx (lower than 1.7)?
In nginx 1.7 you can usethis directive:proxy_ssl_server_name on;This will force nginx to useSNIAlso, you should set the SSL protocols:proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;For earlier version... |
Why do I need Nginx with Puma? | I'm deploying a Rails app to production. It seems that Puma is fast and handles many of the things I want in a web server.I'm wondering if I even need to bother with Nginx, and what I'd be missing out on if just used Puma? | Nginx is a web server and puma is an application server.
Both have their advantages, and you need both.Some examples:Static redirects- you could setup your nginx to redirect allhttptraffic to the same url withhttps. This way such trivial requests will never hit your app server.Multipart upload- Nginx is better suited t... |
Best method to create a c++ app to communicate with nginx | I need to write a C++ interface that can read our data structure and provide the o/p based on query using http protocol.Server NeedIt should be able to serve 100 clients at the same time.Why C++All code is already written in C++. So we need to just write a http layer in C++. That's why I am choosing C++ instead of a mo... | I think I will go forward with Nginx module devlopmenthttp://www.evanmiller.org/nginx-modules-guide.htmlWhy ?It don't require any other library dependency like fastcgi and
other.I can use all feature of nginx inside my module. |
How to change nginx config in amazon elastic beanstalk running a docker instance | After i login and the cookie is set I get error 502. When i read the log i get the error:014/05/17 01:54:43 [error] 11013#0: *8 upstream sent too big header while reading response
header from upstream, client: 83.248.134.236, server: , request: "GET /administration
HTTP/1.1", upstream:After some fast googling i found:h... | I also needed to modify the nginx configuration.Create a script that modifies the nginx configuration (probably you want/etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker.conf) and restarts the nginx service (service nginx restart).You need to execute that script after this nginx config file is written which is aft... |
nginx : Its Multithreaded but uses multiple processes? | I'm trying to understand what makes Nginx so fast, and I have a few questions.As I understand it, Apache either spawns a new process to serve each request OR spawns a new thread to serve each request. Since each new thread shares virtual address space the memory usage keeps climbs if there are a number of concurrent re... | It's not very complicated from a conceptual point of view. I'll try to be clear but I have to do some simplification.The event based servers (likenginxandlighttpd) use a wrapper around an event monitoring system. For example. lighttpd useslibeventto abstract the more advanced high-speed event monitoring system (seelibe... |
Change Host header in nginx reverse proxy | I am running nginx as reverse proxy for the site example.com to loadbalance a ruby application running in backend server. I have the followingproxy_set_headerfield in nginx which will pass host headers to backend ruby. This is required by ruby app to identify the subdomain names.location / {
proxy_pass http://ruby... | You cannot useproxy_passin if block, so I suggest to do something like this before setting proxy header:set $my_host $http_host;
if ($http_host = "beta.example.com") {
set $my_host "www.example.com";
}And now you can just useproxy_passandproxy_set_headerwithout if block:location / {
proxy_pass http://rubyapp.com;
... |
Nginx - wordpress in a subdirectory, what data should be passed? | I've tried so many different things. The point I'm at right now is this:location ^~ /wordpress {
alias /var/www/example.com/wordpress;
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000... | Since your location alias end match, you should just use root. Also, noteverythingis routed through index.php on wordpress afaik. Also, unless you know you need path info, you probably dont. I think you want something like:location @wp {
rewrite ^/wordpress(.*) /wordpress/index.php?q=$1;
}
location ^~ /wordpress ... |
how appoint a subdomain for a s3 bucket? | Good morning,I am using amazon s3 bucket as the image server.
And I want to use a subdomain of my site, how to address this bucket.
eg: a picture is now in:https://s3-sa-east-1.amazonaws.com/nomeBucket/pasta/imag.png, and I access it through this same link.Would that it were so: imagens.mydomain.com.br / folder / imag.... | You need to rename your bucket to match the custom domain name (e.g.imagens.mydomain.com.br) and set up that domain as a CNAME to.s3.amazonaws.com.(in your caseimagens.mydomain.com.br.s3.amazonaws.com.The full instructions are available here:http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html |
When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"? | Can/etc/hostsbe used instead ofresolverwhen usingproxy_pass?I need to perform a proxy_pass to the same nginx machine. Is there a way to resolve the domains using the machine's /etc/hosts file instead of specifying a DNS server thru the "resolver" property?This will save me the additional hops needed to reach the same s... | You can get around this by installingdnsmasqand setting your resolver to127.0.0.1. Basically this uses your local DNS as a resolver, but it only resolves what it knows about (among those things is your/etc/hosts) and forwards the rest to your default DNS. |
Nginx Redirect HTTP to HTTPS and non-www to ww | I'm setting up an Nginx server with an SSL.The domain with the SSL iswww.mydomain.exampleI want to redirect all requests from:http://mydomain.example,http://www.mydomain.example, &https://mydomain.exampletohttps://www.mydomain.exampleI have the following server blocks setup currently:server{
listen 443 ssl;
root /... | The SSL redirect won't work if your SSL certificate doesn't support the non-www domain.
The config is correct but can be reduced to just 1 redirect serverAlso don't forget to reload Nginxsudo service nginx reloadserver {
listen 80;
listen 443 ssl;
server_name example.com;
# add ssl settings
return 301 https:/... |
NGINX try_files + alias directives | I'm trying to serve request to /blog subdirectory of a site with the php code, located in a folder outside document root directory. Here's my host config:server {
server_name local.test.ru;
root /home/alex/www/test2;
location /blog {
alias /home/alex/www/test1;
try_files $uri $uri/ /in... | This isa long standing bug in nginx. But you can work around by using therootdirective again. Kind of a hack, but at least it works.server {
index index.php;
root /home/alex/www/test2;
server_name local.test.ru;
location /blog {
root /home/alex/www/test1;
try_files $ur... |
How do I add new site/server_name in nginx? | I'm just starting to explore nginx on my ubuntu 10.04. I installed nginx and I'm able to get the "Welcome to Nginx" page on localhost. However I'm not able to add a newserver_name.Even when I make the changes insite-available/default. I also tried reloading/restarting nginx, but nothing works. | To build on mark's answer, Debian/Ubuntu distros default configuration file has aninclude /etc/nginx/sites-enabled/*;directive with site configuration file stored in/etc/nginx/sites-available/, a default site is usually included in that dir.For examples beyond the default config, follownginx beginner's guideor seewiki.... |
How to enable dynamic module with an existing NGINX installation | IntroductionFrom NGINX version 1.9.11 and upwarts, a new feature is introduced: dynamic modules.With dynamic modules, you can optionally load separate shared object files at runtime as modules – both third-party modules and some native NGINX modules. (source)My setup and the problemI have NGINX installed from the mainl... | I had the same question, and @vladiastudillo answer was the missing piece I needed.First add the nginx stable repo:sudo add-apt-repository ppa:nginx/stableThen run apt update:sudo apt-get updateAnd get the nginx geoip module:sudo apt-get install nginx-module-geoipThis will download and load the module to/usr/lib/nginx/... |
uWSGI raises OSError: write error during large request | My application uses nginx, with uWSGI on the server side. When I do a large request (with a response time > 4s), the following appears:SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request _URL_ (ip XX.XX.XX.XX) !!!
uwsgi_response_writev_headers_and_body_do(): Broken pipe
[c... | It may be the case that when you upload things, you use chunked encoding.
There is uWSGI option--chunked-input-timeout,
that by default is 4 seconds (itdefaultsto value of--socket-timeout, which is 4 seconds).Though problem theoretically may lie somewhere else, I suggest you to try
aforementioned options. Plus, annoyin... |
Directive Inheritance in Nested Location Blocks | are the following two nginx server blocks semantically the same, or is there any difference? Does the JSON-specific configuration in the first example inherit the settings of the "/" location? Does it in the second example?server {
location / {
# ...
location ~* \.json$ {
# json-specific settings
... | The inheritance of config directives in Nginx is such that directives can only be inherited from contexts higher up the configuration tree and never from contexts on the same level or lower.So, a location block cannot inherit from another location block but a nested location blockcaninherit from the parent location blo... |
nginx conditional proxy pass | i am trying to configure nginx to proxy pass the request to another server,
only if the $request_body variable matches on a specific regular expression.My problem now is, that I don't how to configure this behaviour exactly.I am currently down to this one:server {
listen 80 default;
server_name test.local;
... | Nginx routing is based on the location directive which matches on the Request URI. The solution is to temporarily modify this in order to forward the request to different endpoints.server {
listen 80 default;
server_name test.local;
if ($request_body ~* ^(.*)\.test) {
rewrite ^(.*)$ /istest/$1;
... |
UnicodeEncodeError: 'ascii' codec can't encode character | When uploading files with non-ASCII characters I get UnicodeEncodeError:Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/
Exception Value: 'ascii' codec can't encode character u'\xf8' in position 78: ordinal not in range(128)Seefull stack trace.I run Django 1.2 with MySQL and nginx and FastCGI.This is a... | After investigating this some more I found out that I hadn't set the charset in my main Nginx config file:http {
charset utf-8;
}By adding the above, the problem disappeared and I think that this is the correct way of handling this issue. |
Set Vary: Accept-Encoding Header (nginx) | I have an nginx server and can't seem to find any information on how to send Vary: Accept-Encoding headers for CSS and JS files. Does anyone have info about this?Thanks! | This is from the nginxdocumentation.gzip_vary
syntax: gzip_vary on|off
default: gzip_vary off
context: http, server, locationEnables response header of"Vary: Accept-Encoding". Note that this
header causes IE 4-6 not to cache the content due to a bug (see2).There if you just addgzip_vary on;it should do it's job.Also ... |
NGINX - Reverse proxy multiple API on different ports | I have the following API(s):localhost:300/api/customers/localhost:400/api/customers/:id/billinglocalhost:500/api/ordersI'd like to use NGINX to have them all run under the following location:localhost:443/api/This seems very difficult because of customers spanning two servers.Here's my failed attempt starting with orde... | The three services are being proxied by the same server (as far asnginxis concerned) so must be structured as threelocationblocks within oneserverblock. Seethis documentfor details.If you are just passing the original URI unmodified, you do not need to specify a URI on theproxy_passstatement.server {
{
listen 443;
... |
Change Apache .htaccess file to be used with Nginx | I'm migrating a website from a server that has Apache web-server to another server that is running Nginx web-server, and I wanted to convert the .htaccess files, the problem is not just the syntax but also the file name, is it also".htaccess"or what? | Here's a tool I use:http://www.anilcetin.com/convert-apache-htaccess-to-nginx/It is not 100% accurate but it's pretty good baseAlso, here's a link about converting the rules:http://nginx.org/en/docs/http/converting_rewrite_rules.htmlThis one can help a little:http://wiki.nginx.org/HttpRewriteModule#rewriteEDIT:The file... |
nginx "server_tokens off" does not remove the server header | nginx.conf:server_tokens off;Why could this get ignored, the header is still sent:Server: nginxNo, other included config files do not containserver_tokensconfiguration.Yes, I did restart all services. | To citethe docson theserver_tokensdirective:Enables or disables emitting nginx version in error messages and in the “Server” response header field.According to the docs, it thus doesn't prevent the generation of theServerheader but only prevents the addition of the exact version. If you want to completely remove the se... |
Apache + mod_wsgi vs nginx + gunicorn | I want to deploy a django site (it is the open source edx code on github).I am faced with choosing between usingApache with mod_wsginginx with gunicornI have used Apache with mod_wsgi and it's cool enough, but i have no experience with the second option.Which of these would be a better option in terms of speed and also... | Nginxis a really light and easy to use solution and along withgunicornit allows us to run any wsgi application and scale it easily.
Nginx is better at handling requests since it does not spawn a new process for every request unlike Apache.I have written an answer on how to deploy django with nginx for a related questio... |
Nginx - Only enable SSL if SSL Certificates Exist | I have an issue wherein I am building an nginx reverse proxy for directing to multiple microservices at different url paths.The system is entirely docker based and as a result the same environment is used for development and production. This has caused an issue for me when installing SSL as the SSL certs will only be a... | You can create an additional filessl.confand put here ssl configs:ssl_certificate /etc/nginx/certs/atvcap_cabundle.crt;
ssl_certificate_key /etc/nginx/certs/atvcap.key;Then include from the main config:server_name atvcap.server.com;
include /somepath/ssl.conf*;Make sure to include * symbol - this will n... |
Nginx broken after upgrade to osx yosemite | Nginx was working fine on Mavericks, and now after I upgraded to Yosemite its displayingnginx command not found, I tried to install nginx withbrew install nginxand it displays an errorError: You must brew link pcre before nginx can be installedAndbrew link pcredisplaysLinking /usr/local/Cellar/pcre/8.35... Error: No su... | I had the same problem, that is, after upgrading from Mavericks to Yosemite I got the following error:nginx: [emerg] mkdir() "/usr/local/var/run/nginx/client_body_temp" failed (2: No such file or directory)All I needed to do to solve this issue was to create the folder:mkdir -p /usr/local/var/run/nginx/client_body_temp |
Nginx Config for Cors - add_header directive is not allowed | I am trying add CORS directive to my nginx file for as simple static HTML site. (taken from herehttp://enable-cors.org/server_nginx.html)Would there be a reason why it would complain about the first add_header directive saying 'add_header" directive is not allowed here'My config file sampleserver {
if ($http_origin... | add_headerhas to be placed under eitherhttp,server,locationorif in locationblock.You are placing in underif in server. Move them under thelocationblock.server {
listen 8080;
location / {
root /var/www/vhosts/mysite;
if ($http_origin ~* (https?://[^/]*\.domain\.com(:[0-9]+)?)$) {
... |
Nginx reverse proxy error:14077438:SSL SSL_do_handshake() failed | So i am using following settings to create one reverse proxy for site as below.server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /home/ubuntu/p3;
location / {
proxy_pass https://mysiter.com/;
proxy_redirect... | Seeing the exact same error on Nginx 1.9.0 and it looks like it was caused by the HTTPS endpoint using SNI.Adding this to the proxy location fixed it:proxy_ssl_server_name on;https://en.wikipedia.org/wiki/Server_Name_Indicationhttp://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_server_name |
How can a single nginx virtual server deal with both port 80 and 443? | I have a config file with a virtual server setup, this is running on port 443 for ssl. I would also like this same virtual server to handle non ssl traffic on port 80.I was hoping to do the following but it doesn't seem to work.server {
listen 443 ssl;
listen 80;
server_name example.com;
...
}It looks l... | Removessl on;directive.sslflag inlistendirective is exactly what you need.Seehttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server |
how to serve html files in nginx without showing the extension in this alias setup | I'm having a lot of trouble setting up this alias inside nginx to display my website correctly.The website I'm concerned with should be accessible frommywebsite.com/mrand is different from the site located atmywebsite.com/. The website is located at/fullpath(shortened for simplicity) The site needs to serve three kinds... | Apparently alias and try_filesdon't work together. However, I don't think you need to use alias.location /mr {
default_type "text/html";
try_files /fullpath/$uri /fullpath/$uri.html /fullpath/$uri/index.html /fullpath/index.html;
}Which would try:Exact file.File with .html added.Index in the path.Default index.I ... |
uwsgi IOError: write error | I have a problem with my nginx+uwsgi configuration for my django app, I keep getting this errors in the uwsgi error log:Wed Jan 13 15:26:04 2016 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 296] during POST /company/get_unpaid_invoices_chart/ (86.34.48.7)
IOError: write errorWed Jan 13... | The problem is that clients abort the connection and then Nginx closes the connection without telling uwsgi to abort. Then when uwsgi comes back with the result the socket is already closed. Nginx writes a 499 error in the log and uwsgi throws a IOError.The non optimal solution is to tell Nginx not to close the socket ... |
Nginx convert subdomain to path component without redirect | The idea is to take incoming requests tohttp://abc.example.com/...and rewrite them tohttp://example.com/abc/...That's easy enough to do with a 301/302 redirect:# rewrite via 301 Moved Permanently
server {
listen 80;
server_name abc.example.com;
rewrite ^ $scheme://example.com/abc$request_uri permanent;
}The trick... | # abc.example.com
server {
listen 80;
server_name abc.example.com;
location / {
proxy_pass http://127.0.0.1/abc$request_uri;
proxy_set_header Host example.com;
}
} |
nginx 'proxy_pass' cannot have URI part in location? | I have alocationblock aslocation @test{
proxy_pass http://localhost:5000/1;
}but nginx complains that"proxy_pass cannot have URI part in location given by regular expression..."Does anyone know what might be wrong?I'm trying to query localhost:5000/1 when an upload is complete:location /upload_attachment {
uplo... | Technically just adding the URI should work, because it'sdocumented hereand it says that it should work, solocation @test{
proxy_pass http://localhost:5000/1/; # with a trailing slash
}Should have worked fine, but since you said it didn't I suggested the other way around, the trick is that instead of passing/my/uri... |
Enable gzip compression with Nginx | I am trying to enable gzip compression for components of my website. I use Ubuntu 11.04 server and Nginx 1.2.In my Nginx configuration of the website, I have this:gzip on;
#gzip_min_length 1000;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/c... | I just changedgzip_http_version 1.1;to begzip_http_version 1.0;and then it worked |
Fetching static files failed with 404 in nginx | I'm now deploying an django app with nginx and gunicorn on ubuntu 12.And I configure the nginx virtual host file as below:server {
listen 80;
server_name mydomain.com;
access_log /var/log/nginx/gunicorn.log;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
... | You should usealiasinstead ofroot.rootappends the trailing URL parts to your local path (e.g.http://test.ndd/trailing/part, it will add /trailing/part to your local path). Instead of that,aliasdoes exactly what you want: whenhttp://test.ndd/static/is requested, /static is mapped to your alias exactly, without appending... |
Pass cert password to Nginx with https site during restart | I configured nginx installation and configuration (together with setup SSL certificates forhttpssite) viaansible. SSL certificates are under passphrases.I want to write ansilbe task which is restarting nginx. The problem is the following.Normally, nginx with https site inside asks forPEM pass phraseduring restart. Ansi... | Nginx hasssl_password_fileparameter.Specifies afilewith passphrases for secret keys where each passphrase is specified on a separate line. Passphrases are tried in turn when loading the key.Example:http {
ssl_password_file /etc/keys/global.pass;
...
server {
server_name www1.example.com;
ssl... |
Making nginx check parameter in url | I want to check if a parameter is present in a url in nginx and then rewrite.How can i do that?For e.g if url ishttp://website.com/?mobilethen redirect user tohttp://m.website.com | You better usehttp://example.com/?mobile=1(argument with value). In this case checking is simple:if ($arg_mobile) {
return 302 http://m.example.com/;
}Checking for argument existance is usually done with regexp likeif ($args ~ mobile)but it's error-prone, because it will matchmobileanywhere, e.g.http://example.com/... |
Can nginx be used as a reverse proxy for a backend websocket server? | We're working on a Ruby on Rails app that needs to take advantage of html5 websockets. At the moment, we have two separate "servers" so to speak: our main app running on nginx+passenger, and a separate server using Pratik Naik'sCrampframework (which is running onThin) to handle the websocket connections.Ideally, when i... | You can't use nginx for this currently[it's not true anymore], but I would suggest looking at HAProxy. I have used it for exactly this purpose.The trick is to set long timeouts so that the socket connections are not closed. Something like:timeout client 86400000 # In the frontend
timeout server 86400000 # In the back... |
How to use NGINX as forward proxy for any requested location? | I am trying to configure NGINX as a forward proxy to replace Fiddler which we are using as a forward proxy. The feature of Fiddler that we use allows us to proxy ALL incoming request to a 8888 port. How do I do that with NGINX?In all examples of NGINX as a reverse proxy I seeproxy_passalways defined to a specific upst... | Your code appears to be using a forward proxy (often just "proxy"), not reverse proxy and they operate quite differently. Reverse proxy is for server end and something client doesn't really see or think about. It's to retrieve content from the backend servers and hand to the client. Forward proxy is something the clien... |
How to run CGI scripts on Nginx | I have problem setting up CGI scripts to be run on Nginx, so far I've foundhttp://wiki.nginx.org/SimpleCGIthis stuff but problem is that I can't make perl script run as service so that it will run in background and even in case of restart it will start running automaticallyDo you have any idea? I'm running Centos 5I've... | Nginx is a web server. You need to use an application server for your task, such asuWSGIfor example. It can talk with nginx using its native very effective binary interface called uwsgi. |
Connection refused on nginx docker container | I've installedDocker Toolboxin macOS and I'm following Docker's simple tutorial ondeploying Nginx.I've executeddocker runand confirmed that my container has been created:docker run --name mynginx1 -P -d nginx
docker ps
40001fc50719 nginx "nginx -g 'daemon off" 23 minutes ago Up 23 minutes 0.0.0.0:32770->80/tcp, 0.... | The issue is that yourDOCKER_HOSTis not set to localhost, you will need to use the IP address of your docker-machine, since you are using Docker Toolbox:docker-machine ip default# should return your IP address.SeeDocker Toolbox Docsfor more information. |
Nginx SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share | I got this error in nginx error log:SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshakingI use Let's Encrypt currently. Any ideas to solve this problem? Thank you, guys. | This isn't your problem.The best thing you can do in this situation is just to keep your server reasonably updated and secured.At best for you, the client side of a request was running seriously outdated software, and at worst your server is simply being scanned for vulnerabilities by compromised devices connected to t... |
Change the X-Frame-Options to allow all domains | I am trying to use some site of mine as aniframefrom a different site of mine.My problem is- the other site is always consistently changes his IP address and does not have an domain name.So, I read that you can allo a specific domain by adding this lint to the/etc/nginx/nginx.conf:add_header X-Frame-Options "ALLOW-FROM... | If you set it, then you can only set it to DENY, SAMEORIGIN, or ALLOW-FROM (a specific origin).Allowing all domains is the default. Don't set theX-Frame-Optionsheader at all if you want that.Note that the successor toX-Frame-Options—CSP'sframe-ancestorsdirective— accepts alistof allowed origins so you can easily allows... |
How to avoid nginx "upstream sent too big header" errors? | I'm running nginx, Phusion Passenger and Rails.I am running up against the following error:upstream sent too big header while reading response header from upstream, client: 87.194.2.18, server: xyz.com, request: "POST /user_session HTTP/1.1", upstream: "passenger://unix:/tmp/passenger.3322/master/helper_server.sockIt i... | Came across this error recently.SincePassenger 3.0.8there is now a setting that allows you to set the buffers and buffer size. So now you can dohttp {
...
passenger_buffers 8 16k;
passenger_buffer_size 32k;
}That resolved the issue for me. |
Really logging the POST request body (instead of "-") with nginx | I'm trying to log POST body, and add$request_bodyto thelog_formatinhttpclause, but theaccess_logcommand just prints "-" as the body after I send POST request using:curl -d name=xxxx myip/my_locationMy log_format (inhttpclause):log_format client '$remote_addr - $remote_user $request_time $upstream_response_time '
... | Nginx doesn't parse the client request body unless it really needs to, so it usually does not fill the$request_bodyvariable.The exceptions are when:it sends the request to a proxy,or a fastcgi server.So you really need to either add theproxy_passorfastcgi_passdirectives to your block.The easiest way is to send it to Ng... |
NGINX proxy_pass or proxy_redirect | Need help on Nginx proxy_pass.From outside Nginx URL will be hit like this:http://some-IP:8080/v2/platform/general/activity/plan?.....my downstream service looks like this:http://another-IP:8080/activity/plan?...I want to get rid of/v2/platform/generalfrom original public url and call my downstream service like above.I... | proxy_passandproxy_redirecthave totally different functions. Theproxy_redirectdirective is only involved with changing theLocationresponse header in a 3xx status message. Seethe NGINX proxy_redirect docsfor details.Yourrewritestatement does nothing other than prevent further modification of the URI. This line needs to ... |
DNS Records Redirect www to non-www | I'm usingNamecheapDomains andVultrHosting.I'm trying to redirect DNS www to non-www.www.example.com to example.comI contacted Vultr and asked how to do this with their DNS Manager, they said they would not help as it is self-managed. So I contacted Namecheap, they said they would not help becuase they don't have access... | DNS cannot redirect your www site to non-www. The only purpose of DNS is to point both www and non-www to your server's IP address usingA,AAAAorCNAMErecords (it makes little difference). Thenginxconfiguration is responsible for performing the redirect from www to non-www.Your second server block is intended to redirect... |
how to use a variable inside a nginx "if" regular expression | I have a caching system I need to bypass if the user's name (in a cookie) is found in the $request_uri. I'm trying to do something like this, but can't get the variable to interpolate into the regex. Any suggestions pretty please?I can set the $me variable just fine from the cookie; I just can't get it to interpolate i... | It's not exactly what I asked, but I think it'll work for my purposes. I'm still curious how to interpolate a variable inside a nginx PCRE regex if anyone else knows!set $chk == "need";
set $me "kevin";
if ($uri ~ /by-([^-]+)/) { set $by $1; }
if ($by = $me) {set $chk "";} |
How to set nginx max open files? | Though I have done the following setting, and even restarted the server:# head /etc/security/limits.conf -n2
www-data soft nofile -1
www-data hard nofile -1
# /sbin/sysctl fs.file-max
fs.file-max = 201558The open files limitation of specific process is still 1024/4096:# ps aux | grep nginx
root 983 0.0 0.0 858... | On CentOS (tested on 7.x):Create file/etc/systemd/system/nginx.service.d/override.confwith the following contents:[Service]
LimitNOFILE=65536Reload systemd daemon with:systemctl daemon-reloadAdd this to Nginx config file:worker_rlimit_nofile 16384; (has to be smaller or equal to LimitNOFILE set above)And finally restar... |
http_sub_module / sub_filter of nginx and reverse proxy not working | I am trying to reverse proxy my website and modify the content.
To do so, I compiled nginx with sub_filter.
It now accepts the sub_filter directive, but it does not work somehow.server {
listen 8080;
server_name www.xxx.com;
access_log /var/log/nginx/www.goparts.access.log main;
error_log /va... | Check if the upstream source has gzip turned on, if so you needproxy_set_header Accept-Encoding "";so the whole thing would be something likelocation / {
proxy_set_header Accept-Encoding "";
proxy_pass http://upstream.site/;
sub_filter_types text/css;
sub_filter_once off;
sub_filter .upstream.site s... |
X-Frame-Options in nginx to allow all domains | I'm usingnginxas a reverse proxy for my website.I want to be able to open my website in aniFramefrom a chrome extension new tab html file.For this, I need mynginxto setX-Frame-Optionsto allowalldomains.According tothis answer, all domains is the default state if you don't set X-Frame-Options.My/etc/nginx/nginx.confdoes... | Solved it by changing proxy_hide_header values in/etc/nginx/sites-available/defaultfile like so:proxy_hide_header X-Frame-Options;Needed to restartnginxas well as usepm2to restart mynodejsserver (for some reason, it didn't work till I made a small change to my server and restarted it). |
How to parse several log nginx files using goaccess | I want to parse all my logs of nginx (you can see here):ls /var/log/nginx/
access.log access.log.21.gz error.log.1 error.log.22.gz
access.log.1 access.log.22.gz error.log.10.gz error.log.23.gz
access.log.10.gz access.log.23.gz error.log.11.gz error.log.24.gz
access.log.11.gz access.log.24.gz error.... | Quoting theman pageand assuming you have a Combined Log Format:If we would like to process all access.log.*.gz we can do one of the following:# zcat -f access.log* | goaccess --log-format=COMBINEDOR# zcat access.log.*.gz | goaccess --log-format=COMBINEDOn Mac OS X, usegunzip -cinstead ofzcat. |
Nginx - Do I really need sites-available and sites-enabled folders? | I noticed my install of nginx has three folders calledetc/nginx/sites-available
etc/nginx/sites-enabled
etc/nginx/conf.dDo I really need these if I just want to work directly in theetc/nginx/nginx.conffile and remove theincludelines that include these items innginx.conf? Are these directories used for anything else tha... | No, they are not needed if you define your server blocks properly in nginx.conf, but it's highly suggested. As you noticed, they are only used because of theinclude /etc/nginx/sites-enabled/*;in nginx.conf.For curiosity, is there a reason why you do not want to use them? They are very useful; easier to add new sites, d... |
How to use vue.js with Nginx? | I want to build a single page application with Vue.js using Nginx as my webserver and a my own Dropwiward REST API. Moreover I use Axios to call my REST request.My nginx config looks likeserver {
listen 80;
server_name localhost;
location / {
root path/to/vue.js/Project;
index ... | Add the following code to your Nginx Config, as detailed in the VueRouter docs,here:location / {
try_files $uri $uri/ /index.html;
}Also, you need to enable history mode on VueRouter:const router = new VueRouter({
mode: 'history',
routes: [...]
}) |
Nginx rewrite rule with proxy pass | I'm trying to implement nginx rewrite rules for the following situationRequest:http://192.168.64.76/Shep.ElicenseWeb/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635Should be redirected to:http://localhost:82/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635I tried this with no luck:location /S... | Your rewrite statement is wrong.The $1 on the right refers to a group (indicated by paratheses) in the matching section.Try:rewrite ^/Shep.ElicenseWeb/(.*) /$1 break; |
How to debug lua code inside nginx config? | I want to insert log points (io.write) inside my lua code which itself is in nginx configuration (using HttpLuaModule for nginx).
How to do that?
Access and error logs are not showing them. | When running under nginx, you should use ngx.log. E.g:ngx.log(ngx.STDERR, 'your message here')For a working example, seehttp://linuxfiddle.net/f/77630edc-b851-487c-b2c8-aa6c9b858ebbFor documentation, seehttp://wiki.nginx.org/HttpLuaModule#ngx.log |
How to Remove Client Headers in Nginx before passing request to upstream server? | The Upstream server is wowza , which does not accept the custom headers if I don't enable them on application level.Nginx is working as a proxy server, from the browser I want to send few custom headers which should be received and logged by Nginx Proxy but before forwarding request to upstream server those headers sh... | Theproxy_set_header HEADER ""does exactly what you expect. Seehttps://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header.If the value of a header field is an empty string then this field will not be passed to a proxied server:proxy_set_header Accept-Encoding "";I have just confirmed this is working as d... |
Cloudflare and nginx: Too many redirects | I'm trying to set up NGINX and cloudflare.I've read about this on Google but nothing solved my problem. My cloudflare is active at the moment. I removed all page rules in cloudflare but before had domain.com and www.domain.com to use HTTPS. I thought this could be causing the problem so I removed it. Here is mydefaultN... | After tryouts I found that this is only related to Cloudflare. Because I had no redirect problem before moving to Cloudflare.In my case it was a simple fix like this. Select [Crypto] box and select Full (strict) as in the image.Really, you can try this out first before any other actions. |
PHP Flush that works... even in Nginx | Is it possible to echo each time the loop is executed? For example:foreach(range(1,9) as $n){
echo $n."\n";
sleep(1);
}Instead of printing everything when the loop is finished, I'd like to see it printing each result per time. | FINAL SOLUTIONSo that's what I found out:Flush would not work under Apache's mod_gzip or Nginx's gzip because, logically, it is gzipping the content, and to do that it must buffer content to gzip it. Any sort of web server gzipping would affect this. In short, at the server side, we need to disable gzip and decrease th... |
HTTP to HTTPS Nginx too many redirects | I have a website running on a LEMP stack. I have enabled cloudflare with the website. I am using the cloudflare flexible SSL certificate for https. When i open the website in chrome it shows website redirected you too many times and in firefox has detected that the server is redirecting the request for this address in ... | Since you are using cloudflare flexible SSL your nginx config file wll look like this:-server {
listen 80 default_server;
listen [::]:80 default_server;
server_name mydomain.com www.mydomain.com;
if ($http_x_forwarded_proto = "http") {
return 301 https://$server_name$request_uri;
}
root /var/www/htm... |
Nginx is throwing an 403 Forbidden on Static Files | I have a django app, python 2.7 with gunicorn and nginx.Nginx is throwing a403 Forbidden Error, if I try to view anything in mystaticfolder @:/home/ubuntu/virtualenv/myapp/myapp/homelaunch/staticnginx config(/etc/nginx/sites-enabled/myapp) contains:server {
listen 80;
server_name *.myapp.com;
... | It appears the user nginx is running as (nginx?) is missing privileges to read the local file/home/ubuntu/virtualenv/myapp/myapp/homelaunch/static/img/templated/home/img.png. You probably wanna check file permissions as well as permissions on the directories in the hierarchy. |
Avoid nginx decoding query parameters on proxy_pass (equivalent to AllowEncodedSlashes NoDecode) | I use nginx as a load balencer in front of several tomcats. In my incoming requests, I have encoded query parameters. But when the request arrives to tomcat, parameters are decoded :incoming request to nginx:curl -i "http://server/1.1/json/T;cID=1234;pID=1200;rF=http%3A%2F%2Fwww.google.com%2F"incoming request to tomcat... | I finally found the solution: I need to pass$request_uriparameter:location / {
proxy_pass http://tracking/webapp$request_uri;
}That way, characters that were encoded in the original request willnotbe decoded, i.e. will be passed as-is to the proxied server. |
Remove parameters within nginx rewrite | I'm rewriting URLs in nginx after a relaunch. In the old site I had query parameters in the URL to filter stuff e.g.http://www.example.com/mypage.php?type=4The new page doesn't have these kind of parameters. I want to remove them and rewrite the URLs to the main page, so that I get:http://www.example.com/mypage/My rewr... | Had a similar problem, after a lot of searching the answer presented itself in therewrite docs.If you specify a ? at the end of a rewrite then Nginx will drop the original $args (arguments)So for your example, this would do the trick:location ^~ /mypage.php {
rewrite ^/mypage.php$ http://www.example.com/mypage? per... |
How do I run a long-running job in the background in Python | I have a web-service that runs long-running jobs (in the order of several hours). I am developing this using Flask, Gunicorn, and nginx.What I am thinking of doing is to have the route which takes a long time to complete, call a function that creates a thread. The function will then return a guid back to the route, and... | Celery and RQ is overengineering forsimple task.
Take a look at this docs -https://docs.python.org/3/library/concurrent.futures.htmlAlso check example, how to run long-running jobs in background for Flask app -https://stackoverflow.com/a/39008301/5569578 |
Add nginx.conf to Kubernetes cluster | How can I pass thenginx.confconfiguration file to an nginx instance running inside a Kubernetes cluster? | You can create a ConfigMap object and then mount the values as files where you need them:apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
your config
comes here
like this
other.conf: |
second file
contentsAnd in you pod spec:spec:
containers:
- name: nginx
... |
nginx redirect loop, remove index.php from url | I want any requests likehttp://example.com/whatever/index.php, to do a 301 redirect tohttp://example.com/whatever/.I tried adding:rewrite ^(.*/)index.php$ $1 permanent;
location / {
index index.php;
}The problem here, this rewrite gets run on the root url, which causes a infinite redirect loop.Edit:I need a gener... | Great question, with the solutionsimilar to another one I've answered on ServerFault recently, although it's much simpler here, and you know exactly what you need.What you want here is to only perform the redirect when the user explicitly requests/index.php, but never redirect any of the internal requests that end up b... |
how can I create a file with file_put_contents that has group write permissions? | I am usingfile_put_contentsto create a file. My php process is running in a group with permissions to write to the directory. Whenfile_put_contentsis called, however, the resulting file does not have group write permissions (it creates just fine the first time). This means that if I try to overwrite the file it fails b... | You might what to try setting theumaskbefore callingfile_put_contents: it will change the default permissions that will be given to the file when it's created.The other way (better, according to the documentation) is to usechmodto change the permissions, just after the file has been created.Well, after re-reading the q... |
Get NGINX to serve .gz compressed asset files | Rails 3.1 has a convenient system which can compress files into .gz files. However, instead what I've done is I've moved all the asset files that are created with assets:precompile to a static webserver. This all works, but how can I get nginx to serve the .gz files normally? | 1) ensure you have Nginx > 1.2.x (to proper headers modifications) and compile with--with-http_gzip_static_moduleoption2) Enable this optiongzip on(to serve back-end response with gzip header)3) Setup assets location withgzip_static on(to serveall.css.gz, all.js.gzfiles directly)4) Prevent of etag generation and last-m... |
X-Forwarded-Proto and Flask | I have precisely the same problem described inthis SO question and answer. The answer to that question is a nice work around but I don't understand the fundamental problem. Terminating SSL at the load balancer and using HTTP between the load balancer and web/app servers is very common. What piece of the stack is not re... | You are missing theProxyFix()middleware component. See the FlaskProxy Setups documentation.There is no need to subclass anything; simply add this middleware component to your WSGI stack:# Werkzeug 0.15 and newer
from werkzeug.middleware.proxy_fix import ProxyFix
from flask import Flask
app = Flask(__name__)
app.wsgi_... |
Kubernetes Ingress non-root path 404 Not Found | I have the following that config that works when I try:30080apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: app-deployment
spec:
replicas: 3
template:
metadata:
labels:
name: app-node
spec:
containers:
- name: app
image: myregistry.net/repo/app:latest
... | Your ingress definition creates rules that proxy traffic from the{path}to the{backend.serviceName}{path}. In your case, I believe the reason it's not working is that/appis proxied toapp-service:80/appbut you're intending on serving traffic at the/root. Try adding this annotation to your ingress resource:nginx.ingress.k... |
Configuring Nginx for large URIs | I have a large URI and I am trying to configure Nginx to accept it. The URI parameters are 52000 characters in length with a size of 52kb. I have tried accessing the URI without Nginx and it works fine.But when I use Nginx it gives me an error. --- 414 (Request-URI Too Large)I have configured the large_client_header_bu... | I have found the solution. The problem was that there were multiple instances of nginx running. This was causing a conflict and that's why the large_client_header_buffers wasnt working. After killing all nginx instances I restarted nginx with the configuration:client_header_buffer_size 64k;
large_client_header_buffers ... |
What is the benefit of using NginX for Node.js? | From what I understand Node.js doesnt need NginX to work as a http server (or a websockets server or any server for that matter), but I keep reading about how to use NginX instead of Node.js internal server and cant find of a good reason to go that way | Herehttp://developer.yahoo.com/yui/theater/video.php?v=dahl-nodeNode.js author says that Node.js is still in development and so there may be security issues that NginX simply hides.On the other hand, in case of a heavy traffic NginX will be able to split the job between many Node.js running servers. |
nginx rewrite WITHOUT change url | I want to use rewrite function in my nginx server.When I try "http://www.example.com/1234", I want to rewrite "http://www.example.com/v.php?id=1234" and want to get "http://www.example.com/1234" in browser.Here is nginx.conf file...
location ~ /[0-9]+ {
rewrite "/([0-9]+)" http://www.example.com/v.php?id=$1 bre... | Reference:http://wiki.nginx.org/HttpRewriteModule#rewriteIf the replacement string begins with http:// then the client will be redirected, and any further >rewrite directives are terminated.So remove the http:// part and it should work:location ~ /[0-9]+ {
rewrite "/([0-9]+)" /v.php?id=$1 break;
} |
Is it possible to forward NON-http connecting request to some other port in nginx? | I have nginx running on my server, listening port 80 and 433. I know nginx has a number ways of port forwarding that allows me to forward request like:http://myserver:80/subdir1to some address like:http://myserver:8888.My question is it possible to configure nginx so that i can forwardNON-http request (just thoseplain ... | It is possible since nginx 1.9.0:http://nginx.org/en/docs/stream/ngx_stream_core_module.htmlSomething along these lines (this goes on top level ofnginx.conf):stream {
upstream backend {
server backend1.example.com:12345;
}
server {
listen 12345;
proxy_pass backend;
}
} |
nginx startup fail on mac osx 10.9 mavericks | I've been using nginx for a few months without issue, but after upgrading to Mac OS X 10.9 Mavericks, when trying to start nginx I get this:nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 ... | Yourps ... | egrepcommand is finding itself, not an instance of nginx (look at the "COMMAND" column). Since port 80 is in use, it's likely some other program (maybe the Apache that comes with the OS?) is running and grabbing it. To find out, run:sudo lsof -i:80If it's the system Apache ("httpd") program, you can probab... |
nginx Windows: setting up sites-available configs | I'm trying to set up Nginx on my Windows development environment. I can't find how to create something similar to"sites-enabled"on Linux where Nginx would look for (links to) active virtual host configurations.Is there a way to do something similar with a directory with shortcuts to the actual configuration files and N... | The "sites-enabled" approach as used by some Linux packages of nginx utilizeincludedirective, which understands shell wildcards, seehttp://nginx.org/r/include. You may use it in your own config as well, e.g.http {
...
include /path/to/sites/*.conf;
}Note though that such approach might be very confusing (in pa... |
nginx "server" directive with multiple "server_name" entries: always first one is passed to PHP's $_SERVER['SERVER_NAME'] | My configuration file has aserverdirective block that begins with...server {
server_name www.example1.com www.example2.com www.example3.com;...in order to allow the site to be accessed with different domain names.However PHP's$_SERVER['SERVER_NAME']always returns the first entry ofserver_name, in this casehttp://ww... | SetSERVER_NAMEto use$hostin yourfastcgi_paramsconfiguration.fastcgi_param SERVER_NAME $host;Source:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param |
how to make NGINX serve static content like .js, .css, .html? | Recently I have started using NGINX, I found that we can use it for reverse proxy, serving static content from itself which can reduce load time. I have a Tomcat/JBoss server on my local machine and I want to put NGINX in front of it so that static content will be served from NGINX and rest all by Tomcat/JBoss. My Tomc... | You can addlocationwith regexp:server {
listen 80;
server_name localhost;
location ~* \.(js|jpg|png|css)$ {
root path/to/tomcat/document/root/Test/;
expires 30d;
}
location / {
proxy_pass http://127.0.0.1:8081/Test/;
}
} |
how to deploy django under a suburl behind nginx | I have a django application running onhttp://localhost:12345.
I'd like user to access it via urlhttp://my.server.com/myapp.
I use nginx to reverse proxy to it like the following:... ...
server_name my.server.com;
location /myapp {
rewrite /myapp(.*) $1 break;
... ... # proxy param
proxy_pass http:/... | As the prefix is set in Nginx, the web server that hosts the Django app has no way of knowing the URL prefix. As orzel said, if you used apache+mod_wsgi of even nginx+gunicorn/uwsgi (with some additional configuration), you could use the WSGIScriptAlias value, that is automatically read by Django.When I need to use a U... |
When do we need to use http block in nginx config file? | I am reading nginx beginner's tutorial, on the sectionServing Static Contentthey havehttp {
server {
}
}but when I add an http block I get the error[emerg] "http" directive is not allowed here …When I remove the http block and change the conf file to this, it works fine:server {
listen 80 default_server;
li... | Your doing fine. I guess you are editing /etc/nginx/sites-enabled/default (or the linked file at /etc/nginx/sites-available/default.This is the standard nginx set up. It is configured with /etc/nginx/nginx.conf which contains the http {} statement. This in turn contains an "include /etc/nginx/sites-enabled/*" line to ... |
Kubernetes Ingress network deny some paths | I've a simple kubernetes ingress network.I need deny the access some critical paths like /admin or etc.My ingress network file shown as below.apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-test
spec:
rules:
- host: host.host.com
http:
paths:
- path: /service-mapping
... | I’ve faced the same issue and found the solution ongithub.
To achieve your goal, you need to create two Ingresses first by default without any restriction:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-test
spec:
rules:
- host: host.host.com
http:
paths:
- path: /service... |
How can I implement single sign-on (SSO) using Microsoft AD for an internal PHP app? | I'm vaguely aware that on a computer joined to a domain IE can be asked to send some extra headers that I could use to automatically sign on to an application. I've got apache running on a windows server with mod_php. I'd like to be able to avoid the user having to log in if necessary. I've found some links talking abo... | All you need is themod_auth_sspiApache module.Sample configuration:AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIDomain mydomain
# Set this if you want to allow access with clients that do not support NTLM, or via proxy from outside. Don't forget to require SSL in this case!
SSPIOfferBasic On
# Set this if you h... |
How to change the port of nginx when using with docker | I am a docker beginner and the first thing i did was download nginx and tried to mount it on 80:80 port but Apache is already sitting there.docker container run --publish 80:80 nginxanddocker container run --publish 3000:3000 nginxI tried doing it like this 3000:3000 to use it on port 3000 but it doesn't work .And it d... | When you're starting with Docker you may find helpful information about images at DockerHub. For example with nginx you have a section about how toexpose public ports.You can just use:docker run --publish 3000:80 nginxPort 3000 in your localhost will be forwarded to port 80 which is the port that nginx images use to wa... |
Error while loading shared libraries: 'libpcre.so.0: cannot open shared object file: No such file or directory' | I just installed Passenger 3.0.11 andnginxand got this error:Starting nginx: /opt/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory | The message means what it says. Thenginxexecutable was compiled to expect the PCRE (Perl-compatible Regular Expression) shared library to be available somewhere on LD_LIBRARY_PATH or specified in/etc/ld.so.confor whatever equivalent library-locating mechanisms apply to your operating system, and it cannot find the lib... |
nginx proxy pass Node, SSL? | my nginx server is actually proxying my node backend (which listens on port 3000) with a simple:location /api/ {
proxy_pass http://upstream_1;
}Where upstream_1 is my node cluster defined in nginx.conf (on port 3000).I'm gonna have to add SSL over http connections, so I have the following question: do I only need to co... | If you're using nginx to handle SSL, then your node server will just be using http.upstream nodejs {
server 127.0.0.1:4545 max_fails=0;
}
server {
listen 443;
ssl on;
ssl_certificate newlocalhost.crt;
ssl_certificate_key newlocalhost.key;
server_name nod... |
Correct proxy path in nginx.conf | we have two servers, A and B. Server A is accessed worldwide. He has nginx installed. That's what I have in conf:location /test {
proxy_pass http://localserver.com;
}What it should do, is translate the addreesshttp://globalserver.com/test(that is server A) to internal server addresshttp://localserver.com. However, it... | That should work. Nginx should strip the '/test' path on the upstream local server. So what I can say is that is not the cause. To make it a bit better, try this:location /test/ {
proxy_pass http://localserver.com/;
}The 2 slashes I added at the first 2 lines will avoid mistakenly match '/testABC' and send the wrong ... |
Php has its own /tmp in /tmp/systemd-private-nABCDE/tmp when accessed through nginx | I found strange behaviour concerningphpand/tmpfolder. Php uses another folder when it works with/tmp. Php 5.6.7, nginx, php-fpm.I execute the same script in two ways: via browser and via shell. But when it is launched via browser, file is not in real/tmpfolder: /tmp/'.$name.'.txt');
var_dump(file_exists('/tmp/'.$name.... | Becausesystemd is configured to give nginx a private /tmp. If youmustuse the system /tmp instead for some reason then you will need to modify the .service file to read "PrivateTmp=no". |
Write PHP non blocking applications | I want to write non-blocking applications. I use apache2, but I was reading about nginx and its advantage with respect to apache processes. I am considering changing out apache for nginx. My question is, is it possible to write non-blocking web applications with php and nginx?.Or is a better idea to try and do this wit... | Writing non blocking applications in php is possible, but it's probably not the best environment to do so, as it wasn't created keeping that in mind! You get a pretty decent control over your child processes using the process control libraryPCNTLbut it obviously won't ever offer you same ease of use that other environm... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.