Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Return 503 for POST request in Nginx | I have simple configuration file that is used to server custom 503 error page at a time of maintenance. The relevant part is this:server {
listen 80 default;
root /usr/share/nginx/html;
server_name example.com;
location / {
if (-f $document_root/503.json) {
return 503;
... | I ran into this today. It seems the issue is due to nginx (like most servers) not letting youPOSTto a static file.The solution is to capture 405 errors in your @503 location block, serving
the maintenance page. In addition, you will have to enable
@recursiveerrorpages@, since you are first, intentionally, throwing ... |
Nginx extract a value from a variable or any string | Is there an alternative of using If to extract a value from a variable in Nginx config files?I.eif ($http_referer ~* (?<=url=)([\w-.]*)(?=/) ){
set $proxied $1;
rewrite (?<=/)(.+\.(css|jpg|png|gif|js)) http://$proxied/$1 redirect;
}Thanks | Yes.http://nginx.org/r/mapmap $http_referer $proxied {
default example.com;
"~*(?<=url=)(?[\w-.]*)(?=/)" $p;
} |
Expressjs to production | I am new to expressjs, I want to deploy an expressjs app to production. Based on my googling, here's the setup on rackspace I am thinking:1 Load balancer + 2 server + Run app with foreverMy questions are:What engine shall I use to run the app? nginx?how many app can I run per server?Thank you. | If you are serving static files or using any of nginx's reverse proxy features, you can use nginx. But if not, since your servers are behind a load balancer, nginx isn't necessary at all.The rule of thumb is one node.js/express.js process per core. Have a look atclusterto help you manage this. Make sure your load bal... |
Cherrypy : Do I really need to put it behind a frontend? | I've been working on a python web app using cherrypy and read it'd be more "robust" to use it as a backend, so I gave it a try.Shortly put, running some benchmarks on a page doing some database operations and serving static & dynamic content has shown that plain cherrypy was twice as fast than nginx and memcached, and ... | Yes; it's safe to use CherryPy on its own. |
Why does a variable not work in NGINX `proxy_pass`? | Why does a variable not work inproxy_pass?This works perfectly:location /foo/ {
proxy_pass http://127.0.0.1/;
}This doesn't work at all:location /foo/ {
set $FOO http://127.0.0.1/;
proxy_pass $FOO;
add_header x-debug $FOO;
}I see thex-header: http://127.0.0.1/but the result is 404 so I don't know where it's pro... | The final answer, much aided by @MSalters was more complicated than I could imagine. The reason is that NGINX works differently with variables than with statically entered hostnames - it does not even use the same DNS mechanism.The main issue is that path handling and prefix stripping does not work the same with variab... |
AWS App Runner "Create Failed" on health check | I'm creating my first app on AWS App Runner. I have a simple nginx Docker image that works locally by serving html on localhost:8080.When I try to deploy it, the result is "Create Failed". Upon digging into the CloudWatch logs, I see that the health check failed. The health check is configured to ping the root of the s... | I was able to resolve this by deleting my App Runner app (this is currently the only way to change the configuration-- seethisissue), then creating a new one and specifying the health check to ping port 80. |
What happens if I include "Upgrade" and "Connection" headers on HTTP requests that are not intended to be upgraded to websocket connections? | I have an Nginx server block that proxies requests to a node.js server. This server serves both HTTP content and WS (websocket) content. Is it okay to add upgrade headers on requests that should NOT upgrade to websocket connections?i.e. Using Nginx to proxy to a Node.js server that serves HTTP and WS, would it be good ... | I've found that it works fine in practice as well, althoughat least one userhas had an issue with it.This line:proxy_set_header Upgrade $http_upgrade;Is actually doing what you want because$http_upgradecomes from the header sent by the client. So if the client doesn't request an upgrade, it doesn't get passed along.For... |
How to run django and wordpress on NGINX server using same domain? | I have tried many ways but do not know how to runDjango on example.comandwordpress on example.com/blogThe following running project directory structure for Django and Wordpress.Django app dir- /home/ubuntu/djangoDjango app running successfully on- example.com:8000Wordpress dir- /var/www/html/blogWordpress running succ... | Thanksalexfor helping me out to solve this problem.Here is the solutionDjango app dir- /home/ubuntu/djangoWordpress dir- /var/www/html/blogNGINX Conf fileserver {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name example.com;
location / {
proxy_pass http://127... |
When does socket.io use polling instead of websockets? | I am pretty new to socket.io and have written my first app in node/express/socket.io. Right now everything works great on my nginx server. I want to release my app to the public, but I am gripped with the fear that it just won't work for a lot of people. I have had a few friends test my app and everything went smoot... | The only time a client will downgrade to ajax polling (assuming your server does support it which it does) is when the browser client doesn't support webSockets (e.g. a very old client) or perhaps if some proxy in the client path doesn't support webSockets.webSockets are supported in IE10+ and all recent releases of th... |
Root directory shows 404 in nginx | I am new to nginx server. I tried to set a new url "/images/" for serving images. I edited the bi.site file in site-enabled folder.server {
listen *:80;
access_log /var/log/myproject/access_log;
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_redirect off;
proxy_set_... | this:location /images/ {
root /www/myproject/files_storage;
}results in /www/myproject/files_storage/images path, it would be obvious if you setup error_log. So use "alias" directive instead of "root"http://nginx.org/en/docs/http/ngx_http_core_module.html#alias |
extremely slow HHVM, Wordpress, Nginx | I might be doing something wrong but I am doing a bit of testing between a php-fpm wordpress setup and a HHVM wordpress setup. I've heard & seen many mind blowing results from HHVM, but I'm just shocked at the results I'm getting.Using the following apache testing command I'm getting a much higher performance rate from... | Okay so I finally figured out why this is happening...It is not HHVM that is slow. I am using Vagrant and setting up a shared directory between my host and guest OS. VirtualBox shared folders are extremely SLOW!!! When I placed all my Wordpress files in a different private directory and pointed Nginx to it my requests/... |
How to stop nginx on my Amazon EC2 instance | I am trying to recompile nginx in order to add the page speed module. Never done anything like this before so a little scared! I am the step after doing "make" where I want to stop nginx. The problem is it seems like it restarts itself because my site never goes down and if I keep running the command it keeps stoppi... | It looks like there is an upstart script that keeps Nginx up and running. After running this command I was able to stop Nginx:sudo initctl stop nginx |
Django uwsgi import error | I have a Django project with one app calledsubscribe. In rooturls.pyI use include fromsubscribe'surls.py.I put toINSTALLED_APPSsubscribeand insubscribe'surls.pyI usesubscribe.views.for call my views. When server run aspython manage.py runserverlocally all works fine. But when server run on nginx+uwsgi with virtualenv, ... | Your uwsgi config should includepythonpath=/path/where/lives/settings.py/directive, so python interpreter will know where to find your apps.Find more information about uwsgi config options:http://projects.unbit.it/uwsgi/wiki/Dochttp://projects.unbit.it/uwsgi/wiki/Example |
Redirect request to CDN using nginx | I have a couple of server addreses, like cdn1.website.com, cdn2.website.com, cdn3.website.com. Each of them holds simillar files.Request comes to my server and I want to redirect or rewrite it to a random cdn server.
Is it possible ? | You could try using thesplit clientsmodule:http {
# Split clients (approximately) equally based on
# client ip address
split_clients $remote_addr $cdn_host {
33% cdn1;
33% cdn2;
- cdn3;
}
server {
server_name example.com;
# Use the variable defined by the split_clients block to determin... |
Best caching strategy data that is updated frequently (Redis/Memcached vs Nginx/Varnish vs Materialized view) | I am currently running an AWS EC2 Ubuntu server that fetches data from a Postgres RDS database instance. One of the SQL queries used in a view function for a particular page has a lot of joins in it and runs quite slowly. I've tried to trim down the query and removed some joins that might be bit unnecessary but it stil... | Crudely, you would use a low-level cache like Redis or Elasticache to cache raw data (eg the result of the SQL query); whereas you would use a higher-level cache like Nginx or Varnish to cache the whole HTML page on which the data is being displayed. So which one is appropriate depends somewhat on your usecase. If yo... |
How do I map multiple services to one Kubernetes Ingress path? | How do I set a Kubernentes Ingress and Controller to essentially do what the following nginx.conf file does:upstream backend {
server server1.example.com weight=5;
server server2.example.com:8080;
server backup1.example.com:8080 backup;
}I want one http endpoint to map to multiple Kubernetes servic... | Kubernetes Ingress is incapable of this.You could create a new service that targets server1, server2 and backup1 and use that in the Ingress. But the backends will be used in a round robin fashion.You can create a Deployment and a Service of (stateless) nginx reverse proxies with the config you wish and use that in Ing... |
AWS elastic beanstalk + Nginx + Gunicorn | I am working on creating a Django web app using resources on AWS. I am new to deployment and in my production setup (Elastic Beanstalk i.e. ELB based) I would like to move away from the Django development web server and instead use Nginx + Gunicorn. I have been reading about them and also about ELB.Is Nginx + Gunicorn ... | When deploying Django, one of the recommended deployment methods is usingWSGI(seeDeploying Django).This method of deploying Django is also well supported by AWS Elastic Beanstalk, and they even have aDeploying a Django Application to Elastic Beanstalk.At a high level, you want to do the following:Create a Virtual Envir... |
Exclude one directory from Nginx password authentication | I have setup my Nginx server to have authentication for everything, but I want to exclude all the files under/var/www/html/t/sms/plivofor password authentication. I have tried using different paths but it always asks for a password when I try to access a file under/var/www/html/t/sms/plivofrom my browser.Below is my/et... | Thelocation =syntax matches one URI and not all of the URIs under it. Also, you should use the^~modifier to prevent the regular expressionlocationblocks from interfering. Seethis documentfor the rules regarding the evaluation order forlocationblocks.If you have any PHP files under/t/sms/plivo/you will need to add a nes... |
How to use Xdebug with Laravel on Nginx with PHPStorm on Mac? | Guide on how to setup XDebug with PHPStorm.Versions:PHP 7.0PHPStorm 2016.3.2XDebug 2.5OS X El Capitan 10.11.6 | This guide is only for PHP7, Mac El Capitan, PHPStorm 2016.3Install brewhttp://brew.sh/Install php7brew install php70Install nginxGuide -http://learnaholic.me/2012/10/10/installing-nginx-in-mac-os-x-mountain-lion/Config -https://gist.github.com/kmaxat/c07795ab88677efb843686d075fafa9ebrew install php70-xdebugCreate info... |
Why use nginx as websocket proxy? | So I've been reading up on this whole server set up in which Nginx is used in front of nodejs as a reverse proxy so that it serves the static content while allowing node to do the dynamic stuff. My question is, why would someone want to use the nginx front to reverse proxy to the websocket? If nginx serves the static c... | A WebSocket application keeps a long-running connection open between the client and the server, facilitating the development of real-time applications. The HTTP Upgrade mechanism used to upgrade the connection from HTTP to WebSocket uses the Upgrade and Connection headers. There are some challenges that a reverse proxy... |
Telegram Bot API Webhooks Self-signed Certificate issue | I'm working on a Ruby language server to manage multiple Telegram Bots viasetwebhooksBTW, I'll delivery the server as opensource atBOTServerPROBLEMI have troubles receiving webhook updates from Telegram Bot API Server. I have set a webhook token (Telegram reply "success") but I do not receive any update on the succesf... | I answer myself, to share solution found here:https://stackoverflow.com/a/33260827/1786393the point was not the mentioned nginx configuration, but the PEM file:openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn C... |
Nginx Redirect HTTP to HTTPS and WWW to Non-WWW | I'm having issues with this config:#=========================#
# domain settings #
#=========================#
# Catch http://domain, and http://www.domain
server {
listen 80;
server_name www.domain domain;
# Redirect to https://domain
return 301 https://domain$request_uri;
}
# Catch ... | Adding thessl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;In the 3rd server directive fixed this issue. |
nginx error message - what does "peer" refer to? | In order to debug an nginx error case, I need to fully understand an error log message first. Our nginx writes the particular error log message from time to time.Log message"peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream".What is meant by "peer"?I would like to... | After many hours of debugging we finally found the actual cause of the issue. The error message was produced by a client requesting the nginx without a domain, e.g.https://11.22.33.44/robots.txt. Nginx then forwarded the request to an IIS-server which did not have any default websites bound to https for ip-alone-reques... |
PHP-FPM: Operation not permitted | When I try to open index.php in browser I see the error:No input file specified.In error.log:2013/11/04 22:40:07 [error] 3435#0: *4 FastCGI sent in stderr: "Unable to open primary script: /var/www/index.php (Operation not permitted)" while reading response header from upstream, client: 10.0.2.2, server: localhost, requ... | Problem was in non-existent path of setting session.save_path and not in list of setting open_basedir in php.ini |
Nginx hide forwarded port number [closed] | Closed.This question isoff-topic. It is not currently accepting answers.Want to improve this question?Update the questionso it'son-topicfor Stack Overflow.Closed10 years ago.Improve this questionI'm trying to set up a simple static website, and I have an issue with nginx that's complicated by a number of things, most n... | The root of the problem is not withyoursetup, but with the firstweb forward- it works by redirecting the requested URL (http://www.yoursite.com) to the new URL (http://yoursite.com:8000)So this is already in place, when the request reaches your setup, and you can't change it back to port 80, as your provider blocks it.... |
Redirection if query parameter exists on nginx | I'm using IPB forums. I managed to use friendly urls with nginx server conf modifications. However I need to redirect my old forum's URLs to a redirector php file to get current url of a topic (or forum, member etc.). For example: if url is like/forum/index.php?board=23, I will do a redirection to redirector.php .This ... | Your problem relates to the use of break instead of last. From the documentation:http://wiki.nginx.org/HttpRewriteModule#rewritelast - completes processing of current rewrite directives and restarts the process (including rewriting) with a search for a match on the URI fromall available locations.break - completes proc... |
disable nginx caching for certain file types | I have nginx setup, acting as a reverse proxy to apache.
However, I need to disable caching for gifs.
How can I do this on nginx?Thanks | This should do the trick:set $no_cache "";
if ($request_uri ~* \.gif$) {
set $no_cache "1";
}
proxy_no_cache $no_cache;
proxy_cache_bypass $no_cache; |
Example for several (fastcgi/uwsgi/scgi/proxy_pass) Mojolicious apps in the same nginx virtual host? | I have some Mojolicious-based apps which happily run under Apache2 with mod_cgi and mod_fastcgi.The urls are for example:http://example.org/oneapp/path/info?foo=bar
http://example.org/oneapp?foo=bar
http://example.org/secondapp/path/info?foo=bar
http://example.org/thirdapp/path/info?baz=heh
#etc...I had rel... | Since you haven’t got an answer, I’ll give a correct, but entirely half-baked and code-free, solution. Check theMojolicious::Guides::CookbookfornginxandPlackdeployment. Mix this withPlack::Builderfor deploying multiple applications on the same server. I’d go withStarmanas the server engine probably but that is up to yo... |
Git-based website deployment workflow | On my server, I have two users,www-data(which is used by nginx) andgit. Thegituser owns a repository that contains my website's code, and thewww-datauser owns a clone of that repository (which serves as the webroot for nginx). I want to set up a workflow such that pushing togit's repository causeswww-data's repository ... | Remove the repository owned bywww-dataand follow the solution on thiswebpagefor setting up a post-receive hook in the repository owned bygit. |
Starlette's url_for doesn't create links with https scheme behind Nginx (via uvicorn) | I've tried everything:@Starlette:routes = [
Mount("/static/", StaticFiles(directory=parent+fs+"decoration"+fs+"static"), name="static"),
Route(....),
Route(....),
]@Uvicorn:--forwarded-allow-ips=domain.com
--proxy-headers@url_for:_external=True
_scheme="https"@nginx:proxy_set_header Subdomain $subdomain;
pr... | The problem after all was the usage of * instead of "*" through bash.The result was to have all the filenames returned at the FORWARDED_ALLOW_IPS parameter instead of the character "*". |
Apply nginx-ingress annotations at path level | We are migrating from a traditional nginx deployment to a kubernetes nginx-ingress controller. I'm trying to apply settings at alocationlevel, but can't see how to do so with annotations.For example, we had:server {
listen 80;
server_name example.com;
location /allow-big-uploads {
client_max_body_size 100M;
... | Annotationscan only be set on the whole kubernetes resource, as they are part of the resourcemetadata. Theingress specdoesn't include that functionality at a lower level.If you are looking for more complex setups,traefikhave built acustom resource definitionfor their ingress controller that allows more configuration pe... |
RoR App: "The asset 'application.css' is not present in the asset pipeline" after moving to production server | after moving my Ruby on Rails app to production server (AWS EC2 Amazon Linux 2018.03) pages don't render, because of error "The asset 'application.css' is not present in the asset pipeline" (precompiled files are presents in public/assets):production.logHowever, when I refresh my application (sometimes more then once),... | You can confirm your app/assets/stylesheets folder it should have application.css file and you will have to precompile assets in production environment before go/start server in production environment.
You can precompile assets usingRAILS_ENV=production rails assets:precompileIf it still does not work then you can try ... |
How to enable back TLSv1 and TLSv1.1 on nginx? | My nginx confid files looks like:server {
listen 80;
listen [::]:80;
server_name hostserver.ru www.hostserver.ru;
return 301 https://hostserver.ru$request_uri;
server_tokens off;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name hostserver.ru www.hostserv... | I don't know which ciphers work with TLSv1 and TLSv1.1. But I notice from testing sites with SSLTest, that the GCM ciphers are listed against TLSv1.2 only.You may need to use a more inclusive list of ciphers.For example:ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; |
Node.js in container always get the docker0 ip | I host an node.js server with express.js in a docker container.
The address of my container is 172.17.0.62
And I use nginx to redirect the traffic to 172.17.0.62I can access the my server.
But when I useconsole.log(req.ip + ' ' + req.protocol + ' ' + req.originalUrl);to log the traffic.
req.ip is always 172.17.42.1.
I ... | I haven't used docker - but you should be able to get the information you want from x-forwarded-for:Express.js: how to get remote client addressFrom the above link:var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;Oh and interesting to note - a second answer in the above thread might actually be s... |
nginx 500 error, permission denied for tmp folder | I got 500 from Django admin, when I tried to upload a photo.When I inspect the error.log I found:2014/03/13 23:00:55 [crit] 16478#0: *24 open() "/var/lib/nginx/tmp/client_body/0000000012" failed (13: Permission denied), client: xxxxxxx.xxx, server: xxxxxxx.xxx, request: "POST xxxxxxx.xxx/item/86/ HTTP/1.1", host: "xxxx... | Phew. Solved. As the error message says, this indeed was just a "Permission" issue.Check through "/var/lib/nginx/tmp/client_body/" and make sure the permission is correct at each directory level solve the issue.More details can be found here :http://derekneely.com/2009/06/nginx-failed-13-permission-denied-while-reading... |
change localhost hostname in nginx | I have multiple local sites and I want to configure nginx to have a different host of each website.In /var/www I have 2 sites: site1 and site2Then in /etc/nginx/sites-available/ I created 2 different configurations server for each one. I have the files site1 and site2 which content is like:server {
listen 80;
... | You already figured it out but let me explain a bit why it's working.The first sitesite1should have worked just fine, because the defaulthttpport is 80, and that's whatsite1was listening to, sohttp://site1.comwould have worked just fine.The second config file forsite2was listening to port7777so doing a normalhttp://sit... |
nginx as a proxy for NodeJS+socket.io: everything is OK except for big messages | As explained onnginx's websiteI've used these settings for my nginx to proxy websockets to a NodeJS server:location /socket.io/ {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}Everything works fine and socket.emit() / s... | The "solution" found is to usehaproxyto split the tcp stream between nginx and NodeJS.It is not optimal because it adds yet-another-program in our stack, but it does the job.It seems to me that nginx websocket support is still far from being production-ready. |
Docker load balance using NGINX proxy | I'm trying to load balance an API server using nginx and docker's native DNS.I was hoping nginx will round-robin API calls to all available servers. But even when I specify docker's DNS server as the resolver nginx forward the request to only one server.Relevant section from docker-compose.ymlproxy:
restart: always
... | I should have used SERVICE name as the server name in nginx instead of ALIAS name.Running nslookup on nginx container shows:/ # nslookup api
nslookup: can't resolve '(null)': Name does not resolve
Name: api
Address 1: 172.20.0.7 project_api_1.project_default
Address 2: 172.20.0.5 project_api_3.project_default
Add... |
Serve angular in node vs nginx | just a quick question.What would be more beneficial, serving my angular application via node with a reverse proxy from nginx or just serving it directly from nginx?I would think it would be faster to serve it direcly from nginx. | If there is a clean separation of your client-side code and your server side code (e.g so anything the client needs to run is either pre-built into static files or served using your rest api), then it's far better to serve the client-side files either directly from NGINX or from a CDN. Performance and scaling are bette... |
Nginx reverse proxy with different context path | I'm trying to use nginx to reverse proxy multiple web applications on the same host / port, using a different path to distinguish between applications.My nginx config looks like the following:proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_s... | Well first of all there is nothing like transparently proxying a backend from a root domain to a domain with a added base url.If you want to proxyhttp://xyz/abctohttp://defthen there is no way to have a 100% guarantee to have everything work. You need application specific changesIf you backend API is something which do... |
Thymeleaf template (in Spring boot application) behind reverse proxy not forming url's correctly | I have some trouble getting Thymeleaf to form relative URL's correctly when it is used on a server behind a reverse proxy (nginx in my case).Let's say I have the following location in nginx:location /app {
proxy_pass http://10.0.0.0:8080;
}I have the following Thymeleaf 3 page (index.html):
Hello world!
Th... | Ended up matching the context of the Tomcat server to the desired Nginx location. According to above example, the context would be set to '/app'.Edit:
I set the application context property in theapplication.yml:server:
servlet:
contextPath: /app |
Nginx - how to add header for index.html when using try_files | I have the following config (for an Angular app):location / {
try_files $uri /index.html;
add_header "Cache-Control" "no-cache" ;
}Now I would like to add that header only forindex.html, but not for any other files. How to do that? | using the “=” modifier it is possible to define an exact match of URI
and location. If an exact match is found, the search terminates.so you can use this configure :location =/index.html {
add_header "Cache-Control" "no-cache" ;
}
location / {
rewrite ^(.*) /index.html break;
}you can find more informa... |
How to fix http redirects with Nginx? | I have a webpage where http redirects are a bit broken.The current behavior is this:www.example.com, example.com,http://www.example.com,http://example.com,https://www.example.comall gets redirected tohttps://www.example.comandhttps://example.comgets an error saying refused to connect.I want the behavior to be like this... | You have two independent issues:Your requests all redirect toexample.com, regardless of which specific domain is originally accessed.This happens because the$server_namevariable that you are using is effectively a static variable in a givenservercontext, and has a very distant relationship to$http_host.The correct way ... |
nginx: how to get url args which contain dash? | I'm using nginx variable$arg_to get url args.But I find if the url is like 'http://foobar.com/search?field-keywords=foobar',$arg_field_keywordsor$arg_field-keywordsdon't work.Can I getfield-keywordswith$arg_?Thanks in advance. | I had foundarticle, that has a little trick to deal with your problem.TLDR:You can remap variables with complex names by using the map module as follows:map $is_args $http_x_origin {
default $http_x-origin;
}The trick is that map does not fully parse its arguments. The syntax is: map A X { default Y; }, with:A any va... |
gstreamer streaming to nginx rtmp server | PS: First time gstreamer user here. :)Im trying to stream video from a logitech c920 webcam connected to a beaglebone using gstreamer to an nginx server. But somehow rtmpsink is failing on me. However, with filesink im able to save the video on the beaglebone. Though I still have some frame loss issues and no audio, I ... | Finally figured it out. It was rather simple but on the server side of things.I had to addpublish_time_fix off;in the nginx config for rtmp server.Thanks to thisblog. |
Efficiently using multiple docker containers in a single host | I have a physical server running Nginx, MySQL and serving my PHP website. The server has Multi-Core processor with 16 GB of RAM. This server can handle certain amount of web traffic.Now instead of this single server, if I run multiple docker containers running individual instances of Nginx (App Server) and MySQL (DB Se... | Since all process run on the native host (you can run ps aux on host outside container and see them). There should be very little overhead. The network bridging and IP Tables entries to forward packets to virtual host will add some CPU overhead but I can't imagine that being too onerous. |
In nginx config, how to show something to log file directly in the config file? | I'm config a nginx, and debugging the config file,How to show something from the config file directly to log file?for example:location ..... {
to_log "some string";
} | There is no direct way (on the todo list of the echo nginx module), but this solution seems finehttps://serverfault.com/questions/404626/how-to-output-variable-in-nginx-log-for-debugging |
Rails redirect fails on nginx & unicorn setup | I have set up my up to run on nginx and unicorn as described in Railscasts episode #293.When I try to redirect, such asclass PostsController < ApplicationController
def show
redirect_to posts_path, :notice => "Test redirect"
end
endI get redirected tohttp://unicorn/postsinstead ofhttp://mydomain.com/postsHere's... | This works for me:upstream unicorn {
server unix:/tmp/unicorn.example.sock fail_timeout=0;
}
server {
listen 80;
listen localhost;
server_name www.example.com;
keepalive_timeout 5;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# this is required for HTTPS: ... |
High resolution image upload fails stream_copy_to_stream(): read of 8192 bytes | I am using laravel + twill inside docker containers with php7.4.3-fpm + nginx. Everything works fine appart from when I am trying to upload images of high resolution. If I upload image of 3000x3000px there are no problem as soon as I try to do the same with higher resolution (4500x4500px) I get the following error,mess... | I did find a solution, my problem was with php.ini setting, how lame of me to overlook it.
I fixed it by adding these to the docker entry file.sed -i -e "s/upload_max_filesize = 2M/upload_max_filesize = 64M/g" $PHP_INI_DIR/php.ini
sed -i -e "s/post_max_size = 8M/post_max_size = 64M/g" $PHP_INI_DIR/php.ini
sed -i -e "s/... |
Kubernetes nginx ingress rabbitmq management and kibana | On my AKS cluster I have a Nginx ingress controller that I used to reverse proxy my kibana service running on the AKS. I want to however add another http services through the ingress, rabbitmq management console.I'm unable to get both to work with the following configuration:apiVersion: extensions/v1beta1
kind: Ingress... | What you need to do is set thebasePathfor kibana to/kibanaSee the below urlhttps://www.elastic.co/guide/en/kibana/current/settings.htmlYou are looking to configureserver.basePathto/kibana. Then this will sort the reverse proxying issues and you can keep the MQ one directly on root/You can also setSERVER_BASEPATHenviron... |
Nginx "location ~ ." vs "location ~* \." | Is there a difference between the 3 following directives?location ~* \.(png)$ {
expires max;
log_not_found off;
}
location ~ \.(png)$ {
expires max;
log_not_found off;
}
location ~ .(png)$ {
expires max;
log_not_found off;
}Thank you in advance for having taken the time thus far. | These are three forms of regular expression location block. Seethis documentfor details.The~*operator makes the test case insensitive.The.character has a special meaning in a regular expression: matching any single character (much like?does in shell globs).The\.sequence (an escaped dot) matches a literal dot character.... |
Nginx Reverse Proxy upstream not working | I'm having trouble figuring out load balancing on Nginx. I'm using:
- Ubuntu 16.04 and
- Nginx 1.10.0.In short, when I pass my ip address directly into "proxy_pass", the proxy works:server {
location / {
proxy_pass http://01.02.03.04;
}
}When I visit my proxy computer, I can see the content from the... | Okay, looks like I found the answer...two things about the backend servers, at least for the above scenario when using IP addressses:a port must be specifiedthe port cannot be :80 (according to @karliwsn the port can be 80 it's just that the upstream servers cannot listen to the same port as the reverse proxy. I haven'... |
DKIM : Signature header exists but is not valid | I have configured Postfix with SPF and DKIM but all emails are marked as spam.Here is my domain.db (I use bind9) :...
mail._domainkey IN TXT ( "v=DKIM1; k=rsa; p=ABCD" )I verify with :host -t TXT mail._domainkey.domain.comI receive (OK) :mail._domainkey.domain.com descriptive text "v=DKIM1\; k=rsa\; " "p=ABCD"... | Here's what's going on with your SPF record.Go to this link and change the DNS Server to `Google Public DNS (8.8.8.8)https://www.unlocktheinbox.com/dnstools/spf/luckeo.fr/The results of your SPF will bev=spf a mx ip4:176.58.101.240 ~allNow change it to DNS Advantage (156.154.70.1)The results of your SPF will bev=spf1 a... |
How to map my private ip which change dynamically onto my vps_ip? | I have create a droplet in digitalocean,there is a vps_ip i can use.In my home the way connected to the internet is: route+modem+adsl.I built a wordpress on the local pc on my home.The net status is as below when to connect to the web.WAN:
MAC:ommitted for privacy
IP :public_ip PPPoE
subnet mask:255.255.255.255
gateway... | There are a lot of ways to face this. For me, this is the simplest one without having to install extra software or subscribing to dynamic dns sites.I don't know if it's a temporal problem but ipinfo.io didn't work for me, so I use another service in the solution. Change it if desired.First, in your local PC, write the ... |
WebDAV Specification thumbnail/preview file image | Now I'm using WebDAV protocol for sharing files for writing my own webdav client.I want to implement fetching thumbnails previews from specified file located web server (nginx/Apache/other).
WebServer must generate thumbnail/preview image and return that with PROPFIND request or another way.Is there any property from p... | My answer is brief. There is no standard for this. |
Replacing nginx with uwsgi | It seems that uwsgi is capable of doing almost anything I am using nginx for: serving static content, execute PHP scripts, host python web apps, ...
So (in order to simplify my environment) can I replace nginx + uwsgi with uwsgi without loss of performance/functionality? | As they say in the documentation:Can I use uWSGI’s HTTP capabilities in production?If you need a load balancer/proxy it can be a very good idea. It will
automatically find new uWSGI instances and can load balance in various
ways. If you want to use it as a real webserver you should take into
account that serving ... |
Passenger problem: "no such file to load" -- /config/environment | I've been researching this one and found references to similar problems here and there, but none of them has led to a solution yet. I've installed passenger (2.2.11) and nginx (0.7.64) and when I start things up and hit a Rails URL, I get an error page informing me of a load error:no such file to load -- /path/to/app/c... | Naturally, it just took me posting the question to stumble onto the answer. In order to provide info for anyone else searching on this problem, I'll post some details here.The relevant lines from thenginx.conf:user www-data; # in order to have nginx not run as root
passenger_default_user www-data; # likewise for passe... |
What does the nginx 502 559 error code mean? | I'm getting a "502 559" error in my nginx error logs. I know that the 502 means "bad gateway". What does the 559 mean? | As mentioned by Richard Smith in the comment,559in the nginx log stands for:the number of bytes in the HTML response that Nginx sent to the browserSource:http://nginx.org/en/docs/http/ngx_http_log_module.html#log_formator, as specified in thedocs:$body_bytes_sentnumber of bytes sent to a client, not counting the respon... |
CORS on AWS Elastic beanstalk | I'm new to AWS and usedElastic beanstalkto deploy my rest API (api.example.com) in nodeandS3 bucketwithcloudfrontfor my static website (example.com) in React.When calling the API endpoints from website, the browser is giving the CORS error. How can i prevent that?I'm using following code in the node project for CORSapp... | I've updated the CORS configuration in AWS to and it worked
http://localhost:3000
https://example.com
GET
HEAD
DELETE
PUT
POST
*
|
NgInx as reverse proxy with Kong | I wanna use Kong as my API Gateway, running in a Docker container. Each request must go first through a NgInx server and if the requested uri matches example.com/api it must result in the api, registered inside Kong.To achieve this I've added my API to Kong with the following command:curl -i -X POST --url ipnumber:8001... | You need to tell NGINX to forward the Host header upstream to Kong. You can do that withproxy_set_headerlike so:location /api {
proxy_pass: http://kong;
proxy_set_header Host $host;
} |
Nginx including conf from conf.d but still loading default settings | All configurations are being included and conf test is passed too. But Nginx is still serving the default HTML from/usr/share/nginx/html, instead of location root from conf file in conf.d directory.conf filefrom conf.d directoryupstream django {
server unix:///tmp/server.sock;
}
server {
listen ... | The defaultnginxconfig is in/etc/nginx/nginx.conf. By default that file includes the following lines (at least that is the case on rhel based and arch based distros):include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root ... |
CORS error while making post request to logstash | I have configured Logstash 1.5.2 to consume http input on a linux machine.This is my logstash input configuration:input {
http {
host => "10.x.x.120"
port => "8500"
}
}I can send data to logstash by using curl -XPOST from the linux machine.But when I make a $http.post(url... | I was able to get this running by using reverse-proxy setting for nginx.I modified my URL to be as follows:http://10.x.x.120/logsAnd then made the following changes to the nginx.conf file:location^~ /logs {
proxy_pass http://10.x.x.120:8500;
}Now when ever my application makes an HTTP POST request tohttp://10.x.x.... |
Why use uWSGI and supervisor with a Flask app, and not just supervisor? | I usually run my Flask applications with uWSGI and an nginx in front of it.But I was thinking that the same could be achieved with just supervisor and nginx, so I googled around and found a lot of posts on how to setup and the benefits of the uWSGI-supervisor-nginx stack. I've decided to turn to SO, risking getting axe... | An app server such as gnicorn or uWSGI (used to host the flask applications) is used with nginx. nginx is areverse proxy serverwhich acts as a middleman. This helps with load balancing - handling multiples requests efficiently by distributing workloads over the resources. On top of this, supervisor is just used to moni... |
Compile Flags vs Configuration Options - TLS Heartbeat | In case you missed it - an OpenSSL vulnerability in the implementation of theTLS Heartbeat Extensionhas been making the rounds. For more information seehttp://heartbleed.com/.One of the possible mitigation steps is to recompile OpenSSL with the-DOPENSSL_NO_HEARTBEATSoption to disable the vulnerable extension.Why does a... | I don't have knowledge of the programmers' state of mind when they made this decision but yes - a library is not going to be used in a well-defined scenario or two, it's going to be used however someone coded the main() to call itIf you really want to disable an option then compiling it out seems to me to be the best a... |
How can I reuse server configurations in nginx? | When configuring nginx with a site that has ssl, the examples I find online basically duplicate the location settings. Most examples only have the default root location so it's not that big of a deal, but when you have a few locations and rewrite rules in place duplicating this configuration gets messy to maintain.I've... | There's a similar question onserverfault. Here's their answer:server {
listen 80;
listen 443 default ssl;
# other directives
}Thessl parameteris included as of 0.7.14, which means we can't use it, but it's a good solution if you're on a newer version of nginx. |
How to mask my landing page when user not signed in? | I got my web platform built on ruby on rails athttps://example.comMy landing and about pages are hosted in a Wordpress in other host athttps://examplecms.com.What i would like to achieve is to make users to visithttps://example.comget maskedhttps://examplecms.comexcept when they are logged in as my platform's dashboard... | You can usehttp://nginx.org/r/proxy_passto silently redirect the user to a different page, without changing the URL that's shown to the user within theLocationfield of the browser.To check whether the user is logged in, you can install an error handler viahttp://nginx.org/r/error_pageto redirect the user only if your n... |
Nginx clean urls, how to rewrite a folder as an argument with try_files | I'm writing a simple CMS in PHP. Pages (markdown files) and images are accessed like this (respectively):example.org/?q=about.md
example.org/?i=photo.jpgOptionally, I would like to use clean URLs with Nginx, to make the same requests look like this:example.org/about
example.org/photo.jpgI rather usetry_filesthanifandre... | I was able to get your example to work by simply omitting the=404:location / {
try_files $uri $uri/ /?q=$uri.md;
}
location ~ \.(gif|jpg|png)$ {
try_files $uri /?i=$uri;
}Quotingthe manual:Checks the existence of files in the specified order and uses the first found file for request processing; [...]If none of... |
When does Rails respond with 'transfer-encoding' vs. 'content-length'? | I'm building an API on Rails version 4.1.7/Nginx that responds to request from an iOS app. We're seeing some weird caching on the client and we think it has something to do with a small difference in the response that Rails is sending back. My questions...1) I want to understand why, for the exact same request (with on... | Both responses are valid according to HTTP 1.1, so you need to fix your client code that it can handle both. It is a bad idea to try to fix the server so that that it behave in a way that it does not trigger a bug in the client.
The next version of nginx may behave differently, you users may even have proxies that chan... |
How can I stop nginx logging Amazon Route 53 Health Check requests? | At the moment my AWS health check is hitting my server pretty relentlessly:...
54.228.16.40 - - [14/Jan/2014:10:17:22 +0000] "GET / HTTP/1.1" 301 178 "-" "Amazon Route 53 Health Check Service"
54.248.220.40 - - [14/Jan/2014:10:17:24 +0000] "GET / HTTP/1.1" 301 178 "-" "Amazon Route 53 Health Check Service"
54.232.40.11... | So it turns out that my health check was set up to hitexample.comrather than the ip address: my bad.For the record, I discovered this by adding the$hostvariable to my log formats (see end of line):log_format debug_format '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$ht... |
Rewrite all requests for non existing files to index.php with try_files with Nginx | I am trying to convert trivial htaccess file to Nginx and can't make it work. It returns 404 error.
Here is htaccess content:RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]Here is my current nginx config:server {
listen 80;
server_name domain.biz;
root /var/www/... | How about other php files you call directly? For example an info.php with just aphpinfo();inside?I ask this because your server conf seems to be using try_files just right, but I'm not sure you're serving php scripts right.¿Is your fastcgi pool listening on that sock? ¿Are you sure it isn't listening in port 9000 for e... |
Google Lighthouse error loading webp images | I am trying to improve my performance score on google lighthouse. It was recommending using next-gen image formats, including webp, so I implemented serving webp in place of images where the request accept header includes webp by using Nginx config something like this...map $http_accept $webp_suffix {
default "";
... | Update your lighthouse to version 2.4 onwardsOn prior versions the webp extension was not handled correctlyhttps://github.com/GoogleChrome/lighthouse/issues/3364If that's not working probably You might need to file an issue onGithub |
Using Google App Engine's locations services with proxy | I'm using Nginx as a proxy to filter requests for my AppEngine Java application. GAE's location services (X-AppEngine-country header) works great without the proxy, but now GAE is using the proxy server's IP as client IP, and the X-AppEngine-country header is quite useless - it returns "ZZ" as the country code.I know t... | You already provided all the info needed for the answer:"..App Engine determines this code from the client's IP address". So they actually look at an IP from where the connection was made.Since your proxy sits between the client and AppEngine, AppEngine sees connections coming from proxy IP. No way around it. |
fastcgi_finish_request creates hung connection when open session exists | I have a client side that sends a request that need long processing time, the client send the request in ajax. Once the request is accepted on the Server the client redirects to another page, this is accomplished by fastcgi_finish_request (I am running php-fpm)LongWork.php:client.js:$.ajax({
url: "...",
data: {... | The problem was with session existence, see Edits in Questions for more details |
Flask-Caching use UWSGI cache with NGINX | The UWSGI is connected to the flask app per UNIX-Socket:NGINX (LISTEN TO PORT 80) <-> UWSGI (LISTER PER UNIX-SOCKER) <-> FLASK-APPI have initalized a uwsgi cache to handle global data.
I want to handle the cache with python package flask-caching.I am trying to init the Cache-instance with the correct cache address. The... | Be aware of using of spawning multiple processes for NGINX. Every process handles its own cache. Without an additional layer, it is not possible to access to a cache from different nginx process.This answer was posted as aneditto the questionFlask-Caching use UWSGI cache with NGINXby the OPewrounder CC BY-SA 4.0. |
PDF files protection from external access. Accessible only to authenticated users. WordPress uploads directory | I am running a website and I would like to protect all the PDF files inside the WordPress uploads folder from external access and hotlinking.I am already using a user authentication to protect the posts attached to these files, but the user authentication doesn't protect the direct link to the PDF file or the indexing ... | So, eventually what I found, after trying all the answers and more, was that while the site.conf #1 was working with the logged-in users for PDF files with URLs starting with https://, it was not working with previous uploads that used to have the http:// in the URL. I had to update the wp_posts table tohttps://example... |
My nginx + php-fm webserver is able to serve web pages that have permission 000. Why? | Perhaps i'm missing something extremely basic, but how is it that my web server is able execute and serve content from php files that have permission 000?Here's the file in question:http://178.62.125.162/test.phpLocation is:/usr/share/nginx/html/wordpress/test.phpHere's the ls:---------- 1 deploy deploy 21 May 22 09:40... | Thanks to Alexander Ushakov for providing the answers.The file with the readable permission had been cached by php-fm. Restarting php-fm meant that the cache was cleared and the web server then served the new file with the restricted access. |
V8 engine compiles JavaScript to machine code. So, why node.js isn't faster than C? | According tolanguage benchmarks, JavaScript V8 is faster than other programming languages at regex-dna program. So, why node.js applications (i.e. http server) isn't faster than C applications (i.e. Nginx, Lighttpd)? | Because V8 applications are javascript applications. Even if the javascript is finally compiled to machine code the runtime characteristics are different.For example if you call a function in an object and that object does not define the function the runtime must locate the function by traversing the prototype hierarch... |
How to route .html and .js files as PHP on Nginx FastCGI server? | For web servers using PHP as apache module:AddType application/x-httpd-php .html .htmFor web servers running PHP as CGI:AddHandler application/x-httpd-php .html .htmI have an Nginx server and I want to run .js files and and .htm files as PHP, so I will have full PHP code inside them. Anyone know how to configure the Ng... | Example for .htm, .html fileslocation ~ \.htm$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.htm;
include fastcgi.conf;
}Example for .js fileslocation ~ \.js$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $doc... |
How to enable HTTPS with certobot/letsencrypt on Amazon Linux 2 with nginx | Install certbot/letsencrypt on Amazon Linux 2 and enable HTTPS on nginx (similar process available for apache) | Install certbotsudo yum update
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum-config-manager --enable epel
sudo yum install certbot python3-certbot-nginx
certbot --versionGenerate certificationUse the following command to generate the certification and automatic let the... |
How to install PHP 7.1 on EC2 running on Amazon Linux AMI 2018.03 having nginx as web server? | How to install PHP 7.1 on Amazon EC2 t2.micro Instance runningAmazon Linux AMI 2018.03having nginx as web server?Reference to PHP7 | I followed below steps to installPHP7.1which had alreadyNginx as web serverforAmazon Linux AMI 2018.03#Remove Old PHP
yum remove php*
#Update Reposistory
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
#Update Amazon AMI
yum upgra... |
curl: (7) Failed to connect to port 80, and 443 - on one domain | This question shows research effort; it is useful and clearI have checked the cURL not working properlyWhen I run the commandcurl -I https://www.example.com/sitemap.xmlcurl: (7) Failed to connect
Failed to connect on all portthis error only on one domain, all other domain working fine, curl: (7) Failed to connect to p... | After many search, I found that Hosts settings not correctThen I checknano /etc/hostsThe Domain point to wrong IP in hosts fileI change the wrong IP and its working FineThis is new error Related tocurl: (7) Failed to connect |
How can we set NGINX web server and its RTMP module on mac system? | How can we set NGINX web server and its RTMP module on mac system?I have tried to set up server using below linkhttps://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmphttps://github.com/arut/nginx-rtmp-module/wiki/Installing-via-BuildBut could not run it as it give error as below :-nginx-rtmp-mod... | You can try these, I used the same method to installauth_moduleon my mac.brew tap homebrew/nginxbrew install nginx-full --with-rtmp-module --with-debug |
Change header 'Django administration' text on nginx | I followedthis question's answers to change my django admin panel title header.I tried this:There is an easy way to set admin site header - assign it to current
admin instance in urls.py like thisadmin.site.site_header = 'My admin'But it just works when I'mrunning the page viaPython manage.py runserverMy question is ... | writing this code at the bottom ofurls.pysomehow worked:admin.site.site_header = 'My admin' |
Show a custom 503 page if upstream is down | I am using nginx as a frontend to an apache server. The config file looks like:upstream apache {
server localhost:8000;
}
server {
listen 80;
error_page 503 /www/static/503.html;
# need some magic here #
location /static/ {
root /www/static/;
}
location / {
proxy_path htt... | Something like thisupstream apache {
server localhost:8000;
}
server {
listen 80;
error_page 502 503 /www/static/503.html;
location /static/ {
root /www/static/;
}
location / {
proxy_path http://apache/;
}
}You can append standard error codes together to display a single p... |
Error 102 nginx SSL | I can't get SSL work on my domain. I just get 102 connection refused.Here is the config:server {
listen 443 default_server ssl;
ssl_certificate /etc/nginx/ssl/www.foreningsdriv.se.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
#if the URL with .php tacked on is a valid PHP file, rewrite the UR... | You should remove passphrase from your private key.openssl rsa -in original.key -out unencripted.key |
Ruby on rails with nginx ddos protection | I have rails3 + nginx stack.Several days ago it was ddos attack with lots of GET requests similar to:GET /?aaa2=bbbbbbb&ccc=1234212
GET /?aaa1=bbbbbbb&ccc=4324233First of all I added to application controller rule:before_filter :ddos_check
def ddos_check
params.each do |param|
if (!param[1].nil? && (param[1].is_a... | You should rather consider using a middleware likeRack::Attack. As it's lower in app stack it will filter out malicious request earlier and faster than Rails.Rack middleware for blocking & throttling abusive requestsRack::Attack is a rack middleware to protect your web app from bad
clients. It allows whitelisting, bl... |
Nginx trying to log to /var/logs instead of /var/log? | I noticed when I test my nginx config usingnginx -t, it gives me a warning:nginx: [alert] could not open error log file: open() "/var/logs/nginx/error.log" failed (2: No such file or directory)Which makes sense, since the log path for nginx is actually set up to be/var/log/nginx/not/var/logs/nginx.I scanned the entire ... | Run this command in a terminal (note: capital V):nginx -VDo you find /var/logs there? Your nginx might be compiled with that default file location.[EDIT]I guess that some of your server blocks don't have the "error_log" directive. So nginx tries the default one for them. Note that by default the error_log is always on.... |
Will an Nginx as reverse proxy for Apache help on dynamic content only | I am planning to move all my static content to a CDN so on my server I only have dynamic content left. I now have Nginx set up as reverse proxy to Apache. The static request that came in where directly delivered by Nginx without having to go to Apache.In this case Nginx handled a large portion of the request and I can ... | No, you don't need nginx anymore. |
How to run Docker container with website and php? | I have a landing page and one PHP file to send emails (feedback form). I want to test this form using Docker.I've written this Dockerfile:FROM php:7.4-cli
COPY . /usr/src/app
CMD [ "php", "/mail/contact_me.php"]But it doesn't work for me.I have the directorymailwith the PHP file in the root of the project, but I'm stil... | ADockerfileis used when you want to create a custom image.FROM php:7.4-clispecifies thebase imageyou want to customize.COPY . /usr/src/appcopie thehostcurrent directory.into thecontainer/usr/src/app.CMD [ "php", "/mail/contact_me.php"]specifies what command to run within the container.In your case, I don't think a cust... |
deny all not preventing return redirection | Nginx is behaving unexpectedly for me. Here are two simplified location blocks.This works as expected. Returns 403 error:location / {
deny all;
root /var/www/test;
}I expected a 403 error. However, this returns 301 and redirects:location / {
deny all;
return 301 https://$server_name$request_uri;
}How ca... | In nginx,returndirective is from rewrite module, anddenyis from access module. According tonginx documentand source code, rewrite module is processed inNGX_HTTP_REWRITE_PHASEphase (forreturnin location context), the access module is processed inNGX_HTTP_ACCESS_PHASEphase, rewrite phase happens before access phase, thus... |
Why is nginx claiming there's no terminating semicolon in my `rewrite` statement? | I'd like to redirect a URL to a Django platform (via uwsgi) if and only if a cookie exists. Failing that, I need to defer execution to thecontent_by_luaplugin.Below is my attempt at such logic:location ~* "^/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$" { # match a UUID v4
include uwsgi_params;
if ($cookie_admi... | Bonus answer:Also you could just capture the UUID value during the location matching to avoid the additional regex on the rewrite, like this:location ~* "^/([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})$" { # match and capture a UUID v4
include uwsgi_params;
set $uuid $1;
if ($cookie_admin) {
# if cookie exists... |
multiple django apps with nginx proxy_pass and rewrite | I have a single django-admin app namedmyappthat I would like to deploy multiple instances of on different physical boxes, one per customer. However, I'd like them all to be accessed from a similar domain,mydomain.com/customer1/myapp.I've fiddled with specific proxy settings and tried multiple things suggested on SO, b... | basically, you specify url as part of the proxy_pass directive, the following location directive should do it:location ~ ^/customer1/myapp(/?)(.*) {
proxy_pass http://127.0.0.1:8001/$2;
}seehttp://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_passfor the detailed explanation on how nginx passes the uri |
Unexpected used port 80 on macOS with "It works" result | I'm using macOS and I'm just wondering why port 80 is already used as I need to install my own nginx (as docker container) server. Going tohttp://localhostshows me "It works!". But I don't understand where this comes from, as I didn't installed anything by myself. I thought it could be an Apache server shipped with mac... | There is, indeed, a built-in Apache server inside macOS. To stop it, enter the following command to Terminal:sudo apachectl stop |
How to add CORS (cross origin policy) to all domains in NGINX? | I have created a folder that will be used for serving static files (CSS, images, fonts and JS etc) I will eventually CNAME the folder into a subdomain for usage on a CDN to work with my Magento 2 setup.I want to allow ALL domains ALL access via CORS - Cross Origin Policy and I want to cache the data too. This is what I... | location /cdn-directory/ {
location ~* \.(js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header 'Cache-Control' 'public';
add_header 'X-Frame-Options' 'ALLOW-FROM *';
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Meth... |
How to Remotely force a client to purge a cached website? | We are experiencing an issue where a previous version of our home page is being displayed. Even though there has been changes since then, the web page will always show the old version.This issue stems from us using a WordPress plugin that added aLast-Modified: Tue, 19 Apr 2016 15:18:40 GMTheader to the response.The onl... | If you mean the stylesheets or javascript for example you can update the version of the stylesheet see below for an exampleYou can change toNotice the ?v=1.0 parameter at the end of the source, this works for Javascript also.If you need images and things to update you can find lots here about cache busting hereRefresh ... |
always 403 Forbidden with Nginx .htpasswd | From looking at tutorials such asthisit seems relatively easy to set up .htpasswd authentication.Here's my HTTPS block which is how I'm accessing my site:server {
listen 443;
server_name potato;
root /var/www/html;
ssl on;
ssl_certificate /srv/ssl/cert.pem;
ssl_certificate_key ... | Thankfully I figured this out not long after the posting the question, but I think the following information would be available to others looking to solve similar problems:The relevant logs are not inaccess.log, but rather inerror.log.Running this showed me that the.htaccessfile was not in the expected location. Then I... |
(nginx) Gzip per request vs static gzip | If you configure and install nginx with the flag--with-http_gzip_static_moduleand then you turn on the static gzippinggzip_static on;.HttpGzipStaticModuleWith static gzip when nginx receives a file request it tries to read and return the same file with an extension ".gz".My quesion is: This seems to be a better choice ... | Since that part of the question wasn't answered:Don't gzip images. JPEG and PNG files are already compressed and re-compressing them with gzip may have little effect, and it may in fact result inlargerfile sizes. By default, nginx doesn't compress image files using its per-request gzip module.If you want to reduce the ... |
Django app deployment on nGINX | I want to deploy Django application on nGINX server. I'm using uWSGI. I looked up in many tutorials but none worked.
Django application runs perfectly as a standalone app. What is the simplest way to have the same app running on nGINX??I'm stuck here and want a solution.. :-(my www folder is in/usr/share/nginx/wwwmy si... | Once you have created an dJango application. Just follow these steps:STEP 1.Create a file say uwsgi.ini in your Django Project Directory. i.e besides manage.py[uwsgi]
# set the http port
http = :
# change to django project directory
chdir =
# add /var/www to the pythonpath, in this way we can use the project.app for... |
Why does Gunicorn use port 8000/8001 instead of 80? | I busy setting up a development environment for Django Framework using Gunicorn (as Django service) and NGINX (as a Reverse Proxy).When I look at several tutorialslike thisone andthis one, I see that they use port 8000 and port 8001 (http://127.0.0.1:8000andhttp://127.0.0.1:8001). Is there a special reason not to use p... | NGINX listens on port 80 and forwards to Gunicorn. Gunicorn operates on the 127.0.0.1 IP rather than 0.0.0.0, so it isn't listening publicly, and therefore the only way to access the site externally is through port 80. |
Robust way to deploy a Rack application (Sinatra) | I'm looking for arobust way to deploy a Rack application(in this case a Sinatra app). Requests will take a little time (0.25-0.5 sec waiting on proxied HTTP requests) and there may be a decent amount of traffic.Should I go with a traditional mongrel cluster setup? Use HAProxy as a load balancer? nginx? rackup?What ... | Nginx / Unicorn FTW!Nginx in front to serve static files and unicorn to handle Sinatra app.Benefits: Performance, good load balancing with unix socks and deploy/upgrade without any downtimes (you can upgrade Ruby/Nginx/Sinatra/app without downtime).How-to :http://sirupsen.com/setting-up-unicorn-with-nginx/. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.