Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
How to handle SSL certificates for implementing WhiteLabel option in a web app running on NGINX server
I'm working on a Web App.My app runs on the subdomainapp.mydomain.comI need to WhiteLabel my app. I'm asking my Customers to point to their own website via CNAME to my app.design.customerwebsite.compoints toapp.mydomain.comHere is what I have tried to solve this.I created a new file in/etc/nginx/sites-availablenamedcus...
There are two solutions for this 1- add the ssl certs to the loadbalance: You need to request a cert with all the supported DNS names (app.mydomain.com and design.customerwebsite.com)/ and you need to manage customerwebsite.com domain with Route53. I think that is not possible in your case.2- Do not use ssl on the loa...
Set up nginx to use multiple ssl certificates without having multiple servers [closed]
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, ...
Yes, you can use multiple domains (each with its own SSL certificate) in nginx. You will need a separate server block for each domain in the nginx configuration file. Here's an older reference that can get you startedHow To Set Up Multiple SSL Certificates on One IP with Nginx on Ubuntu 12.04If you are looking to have ...
How to configure nginx's default.conf
I'm trying to configuredefault.confin/etc/nginx/conf.dto show a simple landing page located at/home/ubuntu/project-source/company/entry/index.html.The domains are set up correctly as far as I know to point to the serverA: test24.company.io -> default.conf:server { listen 80; server_name localhost; i...
Ok after many days and hours breaking my head I came to this solution:On GoDaddy's DNS I added these records:A: test24.company.io -> A: sub1.test24.company.io -> A: sub2.test24.company.io -> note:All 3 records point to the same elastic IP, there is no need to set an individual elastic IP for each subdomain.The ngi...
How to prevent web socket DDOS attacks?
I just performed a basic DDOS from my computer:websocket-bench -a 2500 -c 200 wss://s.example.comWhich to my total dismay crashed my server! The WS works by connecting to my nginx proxy:location / { proxy_pass http://sock; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrad...
Either change your authentication logic so Nginx handles it, or implementrequest and connection limitswithin Nginx to control how many connections are accepted and passed to the upstream server
ASP.NET MVC behind NGINX reverse proxy
I am currently working on a project that requires one of our current ASP.NET MVC5 web applications to sit behind a NGINX reverse proxy that the client will control.I am brand new to NGINX so am lacking in knowledge.The reverse proxy will be placed at a sub path. (example below)http://localhost:9999/foo/bar/This will th...
I have now found two solutions for the above...I have opted forsolution twoas it requires no code changes but have successfully tested both solutionsSolution OneApologies, I dont have access to the working test code on this machine but it goes something like the below :Create a base controller and override the Controll...
nginx - client_max_body_size has no effect with ssl configured
When I setclient_max_body_size 30m;without ssl everything works (files up to 30MB are accepted). However when I switch to ssl it completely ignores this directive.My configuration looks like (/etx/nginx/conf.d/my-sites.com.conf):server { listen 443 ssl; server_name my-sites.com; ssl_certificate /etc/nginx/ssl/my-...
I finally found the cause of this problem. Nginx works correctly, however I routed requests to AWS Elastic Beanstalk which uses nginx internally to route requests to inside Docker container.So the misconfiguration was on the side of AWS Elastic Beanstalk. Configuring the AWS fixed the problem.
How to add nginx modules on windows platforme?
I'm trying to test Streaming media files in my local Nginx configuration. I need to add two nginx modules : flv and mp4--with-http_flv_module for Flash Video (FLV) files --with-http_mp4_module for H.264/AAC fileshowever, I'm using Kevin Worthington install :http://kevinworthington.com/nginx-for-windows/, so I'm not e...
I find this link, to building nginx on the Win32 platform with Visual C :http://nginx.org/en/docs/howto_build_on_win32.html
Reverse proxy for a subdirectory with nginx and Play 2.1 apps
GoalSetup multiple Play 2.1 applications with nginx using different subdirectory for each application.App1 running on127.0.0.1:4000should be accessible under127.0.0.1/devApp2 running on127.0.0.1:5000should be accessible under127.0.0.1/testConfigurationnginx.confworker_processes 1; error_log logs/error.log; events {...
Use localdomainslikehttp://test.loc/andhttp://dev.locinstead of relying on subfolders. Althoughapplication.contextshouldwork I saw many posts complaining that they don't...What's more usinglocal domainsis more similar to the final - production enviroment, so it's just easier to debug some url depended things, like ie. ...
Django with Gunicorn different ways to deploy
I've been reading about deploying Django with gunicorn and I wanted to give it a try.I have found at least 3 ways of running a server with gunicorn and django:gunicorn [OPTIONS] [APP_MODULE] # tested locally and worked finepython managy.py run_gunicorn # also works fine locallygunicorn_django [OPTIONS] [SETTINGS_PATH...
Usegunicorn_django [OPTIONS] myprojectif you usemyproject.settings
Recompiling nginx after using apt-get install nginx
I originally installed nginx via apt-get install. It works just fine. Now, I want to install some 3rd party modules and I have to recompile nginx. So I tried to recompile. It went through the motions and then I realized that my original version was still the one that was being used.Do I need to uninstall my original co...
You shouldn't need to uninstall the apt-get version first, but it's a good idea so that you don't inadvertantly walk over your custom recompile with an 'apt-get update' or similar system update in the future.There are a few reasons your recompile may not have worked. Does the installer have the correct permissions to ...
Permission Denied Nginx Docker
I'm using docker compose to boot up a development workspace, consisting of php, nginx and mysql. Everything boots, static html get's served, but when trying to start a laravel app, i get the following error:The stream or file "/home/html/storage/logs/laravel-2019-06-10.log" could not be opened: failed to open stream: P...
Enter the php-fpm container:docker-compose -i -t exec php-fpm /bin/shThen change access rights of storage folder:chmod -r 777 /home/html/storageCause it's local development environment, correct rights doesn't matter.
200 connect() to unix:/tmp/uwsgi.sock failed
I am configuring nginx with uwsgi on EC2, I have check logs in file/var/log/nginx/error.log.I am getting this error:200 connect() to unix:/tmp/uwsgi.sock failed (2: No such file or directory) while connecting to upstreamMy uwsgi.sock location is/var/www/myapp/How can I change the file location fromuwsgi://unix:/tmp/uws...
This might be a problem with classical namespaced Temp, please see this:http://fedoraproject.org/wiki/Features/ServicesPrivateTmpbut you mentioned that you have set your sock location to your app directory, have you done it in your nginx configuration for that virtual host? you will definitely need to restart your web ...
Amazon AWS 307 response and permanent redirect to HTTPS
I have a domain from GoDaddy, with AWS Route53 for managing DNS records. Route53 sends request to a load-balancer.For webserver I have a load-balancer that routes requests to a single (for now) EC2 instance and the nginx in EC2 instance get the request and sends a response to the client.The problem is that when I useht...
It's neither component.This isn't anything from AWS... it's the browser. It's aninternalredirect the browser is generating, related to HSTS...HTTP Strict Transport Security.If you aren't doing it now, then presumably, in the past, you've generated aStrict-Transport-Security:header in responses from this domain, and th...
NGINX location rewrite URL with or without trailing slash
Currently I have this location block:location = /events { rewrite ^ https://totallydifferenturl.com; }This successfully redirects frommywebsite/events, but I want this block to also handlemywebsite/events/.Tryinglocation = /events/?didn't work out.
You need the~operator to enable regex matching, and since you only need to matchwebsite/eventsorwebsite/events/as full strings, you will need anchors^and$around the pattern:location ~ ^/events/?$ ^ ^ ^The^/events/?$pattern matches:^- start of input/events- a literal substring/events/?- one or zero/symb...
NGINX: Redirect a user based on cookie for a specific URL only
I'm building a closed social network and currently when a user is not logged in they will always be redirected to the homepage of my domain.What I would like to do is do the following:Use NGINX to check if a user is logged in (through checking for a cookie) and then when they go to the homepage (mydomain.com) redirect ...
Final correct solution:location ~* ^/$ { if ($http_cookie ~* "wordpress_logged_in") { return 301 http://example.com/newsfeed/; } }
nginx and asterisk server_name?
Is there a way to proxy all traffic to a certain serverunlessthe domain is something different?Basically a*for theserver_nameproperty?server { listen 80; server_name foo.com } server { listen 80; server_name * }Or, is there a way to set a "default" server, and then it would use it if none of the other specific...
As @Valery Viktorovsky's answer says, you can't use a * forserver_name. You can designate aserverblock as the "default" to receive all requests which don't match any others. Seethis postfor an explanation. It would look like this:server { listen 80 default_server; server_name wontmatch.com; # but it doesn't mat...
Nginx: try_files outside location
I'm configuring a pretty standard webserver using nginx. The server is working as expected, however, there is a small configuration detail I would like to understand.My current configuration is:index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?q=$uri; } location ~ \.php$ { try...
You are probably under the impression thattry_fileson server level must work for every request. Not at all. Quite the contrary, it works only for requests that match nolocationblocks.
flutter web built release but nginx route 404
Similar case:flutter-web-app-blank-screen-in-release-modeI have an AWS EC2 cloud server. and I built a flutter web build in my EC2 Server. and cross-connect the flutter web index.html to Nginx.> $ flutter build web 💪 Building with sound null safety 💪 Compiling lib/main.dart for the Web... ...
Try update nginx config. It will work for direct url.location / { try_files $uri $uri/ /index.html; }
Fatal error: Class 'MongoDate' not found when using mongodb php driver 1.1.2 and PHP 7.0.2 - Laravel 5.1
I am trying to configure MongoDB to work with my Laravel 5.1 Homestead instance on a virtual Ubuntu 14.04 machine. I was able to successfully install the latest version of MongoDB which supports PHP 7.0 usingsudo pecl install mongodb(this is correct for 7.0,notsudo pecl install mongoanymore).I then added the extension ...
As you mentioned you're using the new Mongo extension for PHP 7.The class names have changed from the older version, i.e.MongoClientis nowMongoDB\Driver\ManagerMongoDateis nowMongoDB\BSON\UTCDateTimeI'm not sure how backwards compatible everything is, but this should get you started!
Express 4, NodeJS, AngularJS routing
I am using Express 4 to host my AngularJS app on my backend, with Nginx as my frontend server. However html5 mode does not seem to work, as I will get a Cannot /GET error when I try to enter the page link (e.g.http://localhost/login) via the browser. Is there any routing configuration I need to do for my Express/Nginx?...
I'm assuming you are using a "single page" angular app, so one html page that uses ng-view to load all the other partials.In this case you need to do something like this:Express 4:var express = require('express'), app = express(), server = require('http').Server(app), bodyParser = require('body-parser'), ...
How to install Nginx with an exact version on Amazon Linux 2?
How to install Nginx with an exact version on Amazon Linux 2?What I triedsudo yum install nginxsudo amazon-linux-extras install nginx1sudo yum install nginx:1.14.2Both get nginx 1.20.0 or no package available. How can I get other versions, ex: nginx 1.14.2?
You can install any nginx versions.Check this:https://centos.pkgs.org/7/nginx-x86_64/nginx-1.14.2-1.el7_4.ngx.x86_64.rpm.htmlIf you wanna install nginx 1.14.2 follow this:wget https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.2-1.el7_4.ngx.x86_64.rpm sudo rpm -Uvh nginx-1.14.2-1.el7_4.ngx.x86_64.rpm nginx -v
Nginx stat() failed (13: Permission Denied)
Okay so there have been some previous posting of this yet no solution fixes my problem.I have site configured which is just straight up HTML, CSS & JS and I'm trying to add a wordpress site. My config for the wordpress site is as follows.####################### server { listen 80; root /usr/share/nginx/threadtheatre/...
for me this is because selinux enabled, check withselinuxenabled && echo enabled || echo disabledif enabled try to disablenano /etc/sysconfig/selinux SELINUX=disabledthenreboot
Ruby Net::HTTP not decoding gzip?
I haveruby-1.9.3-p327with zlib installed.localhost:80is the nginx simple test page.require "net/http" => true Net::HTTP::HAVE_ZLIB => true res = Net::HTTP.start("localhost", "80") do |http| req = Net::HTTP::Get.new "/" req["accept-encoding"] = "gzip" http.request req end => # res.get_fields "content-encoding" =...
If you usehttp.getit should decode it automaticlly, but it looks likerequestmight not do it for you.There clearly is code to decompress the gzip request here, but only for thegetmethod:https://github.com/ruby/ruby/blob/v1_9_3_327/lib/net/http.rb#L1031
How to inspect POST body in nginx (HttpLuaModule)
My goal is to inspect a body of the POST request and compare it to some list of key-value pairs on nginx. In my situation POST requests will always be in JSON format. Each request will contain akey:valuepair like this:"transaction":"12345"or"transaction":"098765". Mean the key "transaction" will always be there and val...
There are various ways to inspect the POST requesty body in ngx_lua, depending on your needs:Fully buffered way: usengx.req.read_body,ngx.req.get_body_data, andngx.req.get_body_file.Streaming processing way: usengx.req.socketto read and process the request body stream in chunks.
How to test nginx errors?
I'm trying to trigger an nginx error to test my error pages. This is what I tried:server { // ... root /path/to/site error_page 504 502 500 = /html/error/500.html; # absolute path: /path/to/site/html/error/500.html return 500; }But I keep getting the default nginx error. Testing the html is not enough, ...
server { root /path/to/site error_page 504 502 500 = /html/error/500.html; location /get_error { return 500; } }See the docs:http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
development, staging, and production environments rails app
I'm creating an app that in addition to the live production environment requires a development and staging environment. The production environment is currently live and on its own VPS instance. A record:myapp.com 1.2.3.4The development and staging environments will be on their own VPS instance. I've configured the a...
You can set the environment for each instance using therails_envoption. For example:server { listen 443; server_name staging.myapp.com; root /apps/myapp/staging/public; passenger_enabled on; rails_env staging; }
Can we use NGINX as webapp for template engine
I have a requirement for basic html template webapp such as:http://localhost:3000/myapp?param1=hello&param2=Johnis called it should returntext/htmlresponse which looks like this: Nice to see you John. Platform greets you "hello". the name and greeting is templated from param. so template is something like this: Nice...
I was able to solve this using only Nginx to program it using OpenResty's lua module.Thehttps://github.com/openresty/lua-nginx-modulegives ability to program in nginx.conf, where one could use the existing lua libraries such ashttps://github.com/bungle/lua-resty-templatefor templating!myapp.lua:local template = require...
Can't retrieve url GET parameters with Laravel 5.1on remote server
For some reason I can't get any GET parameters from a url in my controllers using theIlluminate\Http\Requestfacade. I tested in multiple controllers, but no success.Using the following code, nothing is returned on the remote server when accessingdomain.com/admin/dashboard?test=test, but on my local machine it returnste...
If anyone runs into this, the problem was with how I set up Nginx for this particular domain.This block in my/etc/nginx/sites-enabled/defaultfile didn't work with query strings:location / { try_files $uri $uri/ /index.php$query_string; }After changing it to the following, everything worked as it supposed to b...
nginx installed successfully but cannot start
I use homebrew to install nginx. However, when I start nginx, it prompts:dyld: Library not loaded: /usr/local/lib/libpcre.1.dylib Referenced from: /usr/local/bin/nginx Reason: Incompatible library version: nginx requires version 4.0.0 or later, but libpcre.1.dylib provides version 2.0.0 Trace/BPT trap: 5Any ideas?
Well, I don't know what causes the problem. I checked my pcre, and it was in latest version. Without option I just uninstall it and reinstall it again...Then it works...
Nginx cookbook v 2.0.0: Cookbook http_gzip_static_module not found
I'm using berkshelf to manage cookbooks, chef 11.6.2, and nginx cookbook v 2.0.0my settings to compile nginx from source:set[:nginx][:source][:modules] = ["http_gzip_static_module", "http_ssl_module"]The provisioning gives me the error:Cookbook http_gzip_static_module not found. If you're loading http_gzip_static_modul...
The nginx cookbook version was increased to 2.0.0 to make an emphasis on breaking changes. Particularly now you should specify all modules withnginx::prefix and do not useextra_modulesat all. So, it should look like this now:"default_attributes": { "nginx": { "source": { "modules": [ "nginx:...
How to handle 404 error request in vuejs SPA with nginx server
I have set up my vue-cli version 3 SPA so that any requests not found in my routes.js file will default to my 404 view as shown in the officialdocumentation:Inserted near bottom ofroutes.jsfile:{ // catches 404 errors path: '*', name: '404', component: () => import(/* webpackChunkName: "NotFoundComponent" */ './v...
I think it is similar to Node solution - you should repeat all your routes in nginx config to return 404 status code correctly, the main idea is that you should use "equals" modifier in locations and defineerror_pageto return sameindex.htmlfile but with 404 status code, example:server { listen 80; server_...
Use variable in lua and nginx
I have a variable$aetthat I initialize in lua, but I wish I could use it in nginx too.Here is my code:location /getIp { default_type 'application/json'; rds_json on; content_by_lua ' if ngx.var.host:match("(.*).nexus$") ~= nil then aet = ngx.var.host:match("(.-)%.") ...
RTFMhttps://github.com/openresty/lua-nginx-module#ngxvarvariableRead and write Nginx variable values.value = ngx.var.some_nginx_variable_name ngx.var.some_nginx_variable_name = valueNote that only already defined nginx variables can be written to. For example:location /foo { set $my_var ''; # this line is required ...
How can I set a range of remote IP addresses without passing a list?
I have this server block:server { server_name doamin.tld; set $maintenance on; if ($remote_addr ~ (127.0.0.1|10.1.1.10)) { set $maintenance off; } if ($maintenance = on) { return 503; } error_page 503 @maintenance; location @maintenance { root /var/www/html/glob...
Use thenginx map directiveto set the$maintenancevalue according to the$remote_addr:map $remote_addr $maintenance { default on; 127.0.0.1 off; 10.1.1.10 off; 10.*.1.* off; } server { server_name doamin.tld; if ($maintenance = on) { return 503; } # ... your cod...
Nginx reverse proxy return 404
My Nginx installed and running, below is the config from/etc/nginx/nginx.conf, I want to forward all/api/*to my tomcat server, which is running on the same server at port 9100(typehttp://myhost:9100/api/appsworks) , otherwise, serve static file under '/usr/share/nginx/html'. Now I typehttp://myhost/api/appsgive an 404....
Theproxy_passstatement mayoptionallymodify the URI before passing it upstream. Seethis documentfor details.In this form:location ^~ /api/ { proxy_pass http://myserver/; }The URI/api/foois passed tohttp://myserver/foo.By deleting the trailing/from theproxy_passstatement:location ^~ /api/ { proxy_pass http://myse...
Nginx does not serve image ( 403 - forbidden error )
I just set up an nginx server. I can visit my webpage ( an "under construction" page ), but although one image is server properly by the server ( named "logo.png" ), another image on the same directory ( I have everything under the root directory of nginx ) is not served and throws a "403 - Forbidden" error ). Below I ...
Probably nginx-user does not have rights to read second file. Options:1) change chmod of that file so it can be read by everyone2) add nginx-user and file-owner-user to the same group and allow group to read that file
Send Redirects To Specific Ports
I have an Rails application server that is listening on port 9000, and is being called through haproxy. All my redirects from that server are being redirected back through port 9000, when they should be sent back on port 80.I am using a combination of haproxy + nginx + passenger. Is there a way to make sure all redirec...
Like elektronaut indicated, this is probably something that should be handled in your proxy's configuration. That said, ActiveSupport::UrlFor#url_for has some information that might be useful. Take a look athttp://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/url_for.rbWhat I think it boils ...
How to remove Cache-control header no-cache
My team and I are working on a Laravel API which communicates with a Vue.js frontend that uses the Apollo client to consume the GraphQL responses.We have an issue with cache-control headers being added to the response.Apollo cannot cache the contents because the response contains this header:Cache-Control: no-cache, pr...
in any middleware you can use this examplepublic function handle($request, Closure $next) { $response = $next($request); return $response instanceof \Symfony\Component\HttpFoundation\Response ? $response->header('pragma', 'no-cache') ->header('Cache-Control', 'no-store,no...
Gitlab behind Nginx and HTTPS -> insecure or bad gateway
I'm running Gitlab behind my Nginx.Server 1 (reverse proxy): Nginx with HTTPS enabled and following config for/git:location ^~ /git/ { proxy_pass http://134.103.176.101:80; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_f...
I run a similar setup and I ran into this problem as well. According to thedocs:By default, when you specify an external_url starting with 'https', Nginx will no longer listen for unencrypted HTTP traffic on port 80.I see that you are forwarding your traffic over HTTP and port 80, but telling GitLab to use an HTTPS ext...
Laravel nginx.conf with official Heroku php buildpack?
I have the following in `nginx.conf in my project rootlocation / { try_files $uri $uri/ /index.php?$query_string; }But only in the/path works, all others are coming up with a 404 error.How can I make Laravel work on heroku with nginx?
This ended up working for me: Procfile:web: vendor/bin/heroku-php-nginx -C nginx.conf public/nginx.conflocation / { # try to serve file directly, fallback to rewrite try_files $uri @rewriteapp; } location @rewriteapp { # rewrite all to app.php rewrite ^(.*)$ /index.php$1 last; }
Local filesystem as a remote storage in Django
I use Amazon S3 as a part of my webservice. The workflow is the following:User uploads lots of files to web server. Web server first stores them locally and then uploads to S3 asynchronouslyUser sends http-request to initiate job (which is some processing of these uploaded files)Web service asks worker to do the jobWor...
The default storage backend for media filesislocal storage.Yoursettings.pydefines these two environment variables:MEDIA_ROOT(link to docs)-- this is the absolute path to the local file storage folderMEDIA_URL(link to docs)-- this is the webserver HTTP path (e.g.'/media/'or'//%s/media' % HOSTNAMEThese are used by the de...
Forwarding port to Node.js app with Nginx and routing
I run my node app onlocalhost:3000and it is serving a default page for the route/. If I accesshttp://localhost:3000the default page is displayed accordingly. I have also running a Nginx server that is basically configured as followed:server { listen 80; server_name localhost; location /node_app { ...
After experimenting a bit around I finally got the configuration right to work exactly how I wanted the server to work:server { location /node_app/ { proxy_pass http://localhost:3000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded...
nginx location fix: Redirect to index.html
I'm runnning nginx v 1.0.4 and we're trying to do the following:location ~ ^/$ { rewrite  ^.*$  /index.html  last; }Basically: If the user gets to the the default domainhttp://www.foo.comorhttp://www.foo.com/redirect them tohttp://www.foo.com/index.htmlWhen I add this to my conf file, I get the following: Starting n...
You can just use rewrite function without locationrewrite ^/$ /index.html last;or for permanent redirectrewrite ^/$ /index.html permanent;to rewrite with parameters, e.g.http://www.foo.com/?param=value->http://www.foo.com/index.html?param=valuerewrite ^/(\?.*)?$ /index.html$1 permanent;
Rails 3, Authlogic, NGINX and HTTP basic authentication no working nicely together
I am in the early stages of building an app using Rails 3. User authentication is powered by Authlogic which I have setup pretty much as standard (as per the example docs) and everything is working as expected locally.I have just deployed the app to a clean server install of Centos 5.4 / NginX / Passenger so staff can ...
I can answer my own question (after several hours of looking in completely the wrong place). A good readup onAuthlogic::Session::Configdid the trick.class UserSession < Authlogic::Session::Base allow_http_basic_auth false end
aws beanstalk nodejs: how to override 60s timeout of nginx
I want to increase the default timeout of nginx in a nodejs environment in AWS elastic beanstalk, i'm following this guide:https://medium.com/swlh/using-ebextensions-to-extend-nginx-default-configuration-in-aws-elastic-beanstalk-189b844ab6adbut it's not working, if i upload my application i receive this error Unsuccess...
.ebextension method is not working now.Please try.platformmethod.Please create a folder called.platformin your project root folder..platform/ nginx/ conf.d/ timeout.conf 00_myconf.configContent of File 1 -timeout.conf(Inside.platform/nginx/conf.d/folder)keepalive_time...
What's the difference between OpenResty and Nginx?
As a novice web developer, I tend to use Nginx when deploying & running my Larvel PHP sites.I've recently come across OpenResty and, from what I believe, it appears to be webserver software like that of Nginx.As someone who is always looking to improve the websites I make, will using Open Resty over Nginx improve the d...
OpenResty is an enhanced version of Nginx, which combines Lua and Nginx. Unless you are planning to use Lua, there will be no benefit of choosing OpenResty over Nginx. Since you are running Laravel based website, there will be no benefits.
Google Cloud Run website timeouts when content length is between 4013-8092 characters. What is going on?
This issue happens on a pure PHP files served by Nginx & PHP-FPM. I've stumbled upon this issue while developing my website using Symfony but the problematic content length range is 3702-15965 for that (I wonder why it's different than vanilla PHP).What I've tried so far:Timeout duration is 15 seconds but I've tried in...
Funnily enough, I've solved the issue while writing the question. Addingfastcgi_buffering off;to Nginx config fixes the issue.But I still don't understand what was the problem and why disabling buffering fixed it. So if anyone can explain it I don't mind marking that answer as solution.
nginx - how to create /status with stub_status
I'm trying to create an /status to use with newrelic, but it's always returning 404.$ curl 127.0.0.1/status 404 Not Found 404 Not Found nginx/1.17.1 Here is my nginx conf file (it's uses certbot as well).server { server_name mysite.com api.mysite.com painel.mysite.com; location / { root /var/www/mysite-p...
Remove:location = /status { <============== HERE stub_status on; default_type text/plain; access_log off; allow 127.0.0.1; deny all; }And just create a new config filestatus.confwith the following content:server { listen localhost; server_name status.localhost; keepa...
Symfony 4, .env files and production
.env files are very handy with docker, kubernetes, etcBut what if I have simple nginx server without any orchestration and a pack of cron workers and a pack of daemons(systemd/supervisord/etc)?I can write these env variables to nginx server section, but I have to set up hundreds of env variables to each cron worker or ...
First of all, not all variables need to be specified using environment variables. Keep variables that do not differ per system in a separate yaml file.When you have just one environment per server you can specify the environment variables globally in/etc/environment. (Might be different depending on your Linux flavour)...
Redirect/rewrite nginx location to .sock file without prefix
I have one server that has several APIs running on it. One of them isusers-DBThe following gets down to gunicorn just fine:location /usersDB/ { include proxy_params; proxy_pass http://unix:/home/ubuntu/projects/UsersDB-api/app.sock; }Except when I try to access the usersDB API's /helloWorld route, and look in t...
Use a separating:. For example:proxy_pass http://unix:/home/ubuntu/projects/UsersDB-api/app.sock:/;Seethis documentfor details.
How to configure gitlab to use existing postgres server
When installingGitlabby default Nginx and Postgres .. among other things are installed regardless of whether you have them already or not. So since I have these two already, I am trying to configure gitlab to use them, I have done this for Nginx, Using:$ vi /etc/gitlab/gitlab.rb: # Disable GitLab's nginx completely ng...
According tothis doc, put this in/etc/gitlab/gitlab.rb:# Disable the built-in Postgres postgresql['enable'] = false # Fill in the connection details for database.yml gitlab_rails['db_adapter'] = 'postgresql' gitlab_rails['db_encoding'] = 'utf8' gitlab_rails['db_host'] = '127.0.0.1' gitlab_rails['db_port'] = 5432 gitla...
nginx + nodejs configuration
I have a problem with my current nginx configuration. What I am trying to do is:For requests without any path, get the index.html (works)Get existing files directly (works)If the requested file or path does not physically exist, proxy request to nodejs (404)I have tried several configurations found here on stackoverflo...
I think I figured out what you were trying to do. The proper way is to usetry_filestogether with a named location.Try with the following configuration:# IP which nodejs is running on upstream app_x { server 127.0.0.1:3000; } # nginx server instance server { listen 80; server_name x.x.x.x; #access_log /...
nginx+uWSGI: dynamic vs emperor mode
I am doing multi-application nginx+uWSGI setup and I wonder if I should use dynamic mode of uWSGI as documentedhere(under Dynamic apps) or theEmperor mode. I am slightly more inclined to use the emperor mode but maybe it is not the best choice. What are pros/cons of each?
Emperor mode is for handling multi-application environments. It basically monitors the directories you specify for new apps & events you want it to respond to.Pros:You can gracefully reload a site when you update your code by touching the vassal file.Apps respawn on crashes & reboots.Scales very nice if you need to add...
Nginx services fails for cross-domain requests if the service returns error
I am making a cross domain request in my web app.I have set the CORS headers on Nginx. Everything is working fine except when the service returns an error like 404, 400, 500 etc, instead of receiving the error code, the service is failing with an error saying that theOrigin *********** is not allowed by Access-Control-...
Answer foundhere:Unfortunately add_header won't work with status codes other than 200, 204, 301, 302 or 304. You can find this in the documentation here.You may be able to use this plugin to do what you want:http://wiki.nginx.org/NginxHttpHeadersMoreModule
uwsgi + python + nginx + willy nilly file execution
I'm using uwsgi on Nginx to run some Python code.I'd like to bind uwsgi to a directory and make it render any .py file that I call from the server in the browser. I'm thinking like PHP, here (/index.php executes that file, /login.php executes that file).Is this a possibility? Or am I only able to explicitly specify a s...
WSGI is not like PHP. You can't just point uwsgi to a directory with a bunch of .py files. In fact, never, ever make your python modules available in a public directory, accessible from the server. You need to hook uwsgi up to a WSGI application, preferably a framework. Read more about WSGIhere. Check outbottlewhich is...
Nginx - How do I know when $http_referer is not set or empty?
How do I know when the nginx variable $http_referer is not set or empty?I receive some requests that don't have a http referer. In nginx logs $http_referer appears like that: "-". What I am trying to do is to "return 403;" if the $http_referer is not set or empty as in this case.Thanks!
http://nginx.org/en/docs/http/ngx_http_referer_module.html#valid_referersvalid_referers server_names ~.; if ($invalid_referer) { return 403; }
Should I user Apache or Nginx & Passenger or Mongrel for my Rails application
I have a Ruby on Rails application that will be a CMS in way which means it's mostly DB intensive. I expect it to have decent amount of traffic so before designing I'm choosing what servers to use. Most important for me is performance.I heard good things about Nginx and many developers in the Rails community recommends...
I'd second for Passenger + Nginx. Very low memory and it's not too difficult to setup. What type of server are your deploying too? Specs? OS? I'd take that into consideration as well considering your available hardware. If you've got enough memory already, then it shouldn't be an issue whether its Passenger or Apache, ...
AWS EB: Error during WebSocket handshake: Unexpected response code: 400
There is a Laravel/Vue.JS app hosted on AWS behind a Classic Load Balancer (Elastic Beanstalk) and proxied internally via Nginx down to socket.io server. SSL is terminated on the Nginx.This is the nginx config:location /socket.io { proxy_pass http://127.0.0.1:6001; proxy_http_version 1.1; proxy_se...
Is your ELB using HTTP/HTTP listeners or TCP/SSL listeners? Websockets only works on the latter protocol types. Change the listener to TCP and it will work.Alternatively, if you built your environment using CLI or API, you can also rebuild your ElasticBeanstalk App using an Application Load Balancer (ALB) instead of a ...
The $document_root variable cannot be used in the "root" directive
While setting up my nginx configuration I came upon this. Does anyone have any idea on why this happens exactly?root /folder/my_root; index index.php index.html index.htm; error_page 404 /404.html; location = /404.html{ root $document_root/error_pages; //FAILS HERE with the error in the title internal; }
This variable is set byrootdirective. You cannot use it inrootdirective itself, because it will lead to infinite loop.Seehttp://nginx.org/r/rootThepathvalue can contain variables, except$document_rootand$realpath_root.Use your own variable instead.set $my_root folder/my_root; root /$my_root; ... location = /404.html {...
Nginx fail on Docker deployment to Amazon
I am trying to deploy .net asp web api application in Docker container to Amazon via elasticbeanstalk, but here is what I got:ERROR: Failed to start nginx, abort deployment ERROR: [Instance: i-ecf0d365] Command failed on instance. Return code: 1 Output: nginx: [emerg] invalid host in upstream "172.17.0.2:5000/tcp" in /...
The error messagenginx: [emerg] invalid host in upstream "172.17.0.2:5000/tcp"shows anupstream serverparameter with the spurious characters/tcpfollowing the port number. Seeupstream module documentation.@Fishman confirmed that the erroneous parameter appeared within thenginxconfiguration file, and that this file was ge...
Launchd not loading nginx on startup
I installed NGINX with homebrew then I got info and followed the instructions to load the launchd plist$ brew info nginx nginx: stable 1.6.2, devel 1.7.7, HEAD ... To load nginx: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist Or, if you don't want/need launchctl, you can just run: nginxThe prob...
This is what worked for me:sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plistThe trick to this is that Mac OSX won’t let anything other than “root” or “system” level services use a port number below 1024.Read more here:http://derickbaile...
Homestead 502 Bad Gateway instead of Whoops for PHP errors
My Homestead Vagrant virtual machine is returning me a502 Bad Gatewayinstead of a Laravel Whoops error for some PHP errors (like class not found, some kind of parse errors etc ...).Does someone have the solution for briging Whoops for all PHP errors ?I could get the error reading manually/var/log/nginx/.app-error.logli...
After some searches I found a working solution.I have to add the following lines to my/etc/nginx/nginx.conf:http { ... fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; ... }Dont forget to edit with root rights withsudosudo nano /etc/nginx/nginx.confAnd then restart nginxsudo /etc/init.d/nginx restartSour...
nginx webdav could not open collection
I have built nginx on a freebsd system with the following configuration parameters:./configure ... –with-http_dav_moduleNow this is my configuration file:user www www; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; # ...
It turns out that the webdav module in-built in nginx is broken and to enable full webdav, we need to add the following external 3rd party module: nginx-dav-ext-module.Link to its github:https://github.com/arut/nginx-dav-ext-module.gitThe configure parameter would now be:./configure --with-http_dav_module --add-module=...
Nginx won't start, says "could not build test test_types_hash"
Here's my nginx.conf:user www-data; worker_processes 1; worker_rlimit_nofile 8192; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 2048; # debug_connection 192.168.1.1; # multi_accept on; } http { server_tokens off; include mime.types; access_log /var...
After banging my head against the wall for a couple of minutes, I just decided "what the heck, I'll fix the first error and see what happens." Lo and behold, removing the extraneous text/javascript MIME type in the gzip_types declaration fixed the problem.Hope this is helpful!
Unicorn/Nginx process missing, socket open
I am trying to deploy code using Capistrano, and it fails ondeploy:startordeploy:stopbecause the Unicorn process is already killed. However if I try tocap deploy:start, I get a stderr claiming thatAddress already in use - /tmp/my_app.socket. How would this happen, and how might I get out of this mess?
Still not sure how this happens, but the following solution seems to work:lsof /tmp/my_app.socket- lists the pidskill -9 pid- (replace 'pid' with one of those listed)Thencap deploy:startfrom the local terminal.
Connecting my domain name on digital ocean droplet
I created a small hello world node app, then i hosted the app on digital ocean droplet, after that i can access my application onhttp://my_public_ip:3000Felt happy 😍Then i bought a domain name calledhelloworld.tkfree domain from freenom.com After that i install nginx as a webserver in my droplet then i added a reverse...
First, remove the forwarding and you need to change the nameservers of the domain in your domain DNS management if your domain is somewhere other than DigitalOceanAdd below nameservers:ns1.digitalocean.com ns2.digitalocean.com ns3.digitalocean.comNow check if they are propagating by using whatsmydns.net (Enter your IP ...
Angular SSR 'Failed to lookup view' on production (Ubuntu, Nginx)
Following up the official Angular tutorial on setting up SSR using Express server:https://angular.io/guide/universal#configure-for-universalThe tutorial would setup paths like this:... const DIST_FOLDER = join(process.cwd(), 'dist'); ... app.set('views', join(DIST_FOLDER, 'browser'));This works pretty well on the local...
Using the following piece of codeconst DIST_FOLDER = join(process.cwd(), 'dist'); app.set('views', join(DIST_FOLDER, 'browser'));means that the view engine will look for views in this directory:/dist/browserThe current working directory corresponds to the directory where the node process was started from.So if you want...
Errors adding Environment Variables to NodeJS Elastic Beanstalk
My configuration worked up until yesterday. I have added thenginx NodeJS https redirect extension from AWS. Now, when I try to add a new Environment Variable through the Elastic Beanstalk configuration, I get this error:[Instance: i-0364b59cca36774a0] Command failed on instance. Return code: 137 Output: + rm -f /etc/ng...
I had this problem as well and Amazon acknowledged the error in the documentation. This is a working restart script that you can use in your .ebextensions config file./opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh: mode: "000755" owner: root group: root content: | #!/bin/b...
Update Nginx config file in a container with zero down time
We are using Nginx as a reverse proxy for docker-cloud services. A script is implemented to update the config file of Nginx whenever new service deploys on docker cloud or if service gets new url on docker-cloud.The Nginx and the script have been run in a docker container separately. The Nginx config file is mounted in...
Shall I recreate the Nginx container after each update? if so, how?No, You just need to reload nginx service most of the time. You can use:docker exec nginxcontainername/id nginx -s reloadordocker kill -s HUP nginxcontainername/idAnother optionwould be using a custom image and check nginx config checksum and reload ngi...
nginx returns Internal Server Error when uploading large files (several GB)
I have an Artifactory behind nginx and uploading files larger than 4 GB fails. I am fairly certain that this is nginx's fault, because if the file is uploaded from/to localhost, no problem occurs.nginx is set up to haveclient_max_body_sizeandclient_body_timeoutlarge enough for this not to be an issue.Still, when upload...
The problem in my case was insufficient disk space mounted on root. I have a huge disk mounted on/home, but only had about 4 GB left on/. I assume that nginx was saving incoming request bodies there and after it had filled up, the request was shut down.The way I fixed it was to add those lines to thenginx.conffile (not...
How to get part of the $host variable in nginx?
I need to get only part of the $host variable. Domain is in the form img1.domain.comand I need to get "domain.com" and then use it in redirect.I am trying it wrong like this:$host ~* img[0-9]\.(.*); set $host_without_img $1;I know it would work, if I would put in in IF condition like this:if ($host ~* img[0-9]\.(.*)) {...
You can usemap, something like this:map $host $host_without_img { default ...; ~*img[0-9]\.(?.*) $x_host_without_img; }
Rails Domain Constraints ( to serve multiple domains )
$ rails -v Rails 4.2.1$ ruby -v ruby 2.2.2p95 (2015-04-13 revision > 50295) [x86_64-linux]I am building an API for a mobile app, which will have an admin interface to it. What i'm attempting to do, is run this through nginx using unicorn ( which I have running on my dev environment)I have 2 domains routed to the exact...
With the fine help of the great people in#RubyOnRailsonircI got this figured out. So thankscrankharderandsevenseacatfor your input and advice.What I ended up with was this:class DomainConstraint def initialize(domain) @domains = domain end def matches?(request) @domains.include? request.host end endan...
symfony/process - Process silently not starting
In a fresh symfony2-project (installation as describedhere), I would like to start a console-process as part of a request. The app runs on a "standard" ubuntu 14.04 box with nginx + php-fpm.Consider this controller-code:get('kernel')->getRootDir(); $env = $this->get('kernel')->getEnvironment(); $command...
Your process most likely dies before it manages to finish its work. It's because PHP kills it after the response is returned back to the client and connection is closed.Process::start()is used tostart a process asynchronously. You need to eitherwait()for it to finish or check if it has finished yet withisRunning():$pro...
Nginx: X-Accel-Redirect not working in files with know MIME extension
I am developing a webapp and X-Accel-Redirect header works fine only in files without extension. For some reason, if I add an extension to the file name the X-Accel-Redirect doesn't work.Working example:X-Accel-Redirect: /protected_files/myfile01.zNon-working example:X-Accel-Redirect: /protected_files/myfile01.zipI'm u...
The error was due to a conflict in rules in nginx config file.So, the solution was:location ^~ /protected_files { # ^~ needed according to the [nginx docs][1] to avoid nginx to check more locations internal; alias /path/to/static/files/directory; } #avoid processing of calls to unexisting static files by my ap...
bash script Syntax error: word unexpected (expecting "do")
I'm trying to run this dropbox script on my nginx server , but im getting:Syntax error: word unexpected (expecting "do")I copy pasted the script for a website, and I tried removing special characters, but im still getting the same error.script:#!/bin/sh # /etc/init.d/dropbox ### BEGIN INIT INFO # Provides: dro...
Probably you managed to insert windows line endings when you copy and pasted. If you have dos2unix, use it. (dos2unix scriptfile) Otherwise, there are a number of similar utilities.
nginx prevent loading from cache
I am updating my site frequently after finishing updates my clients reporting that old images & scripts are getting loaded instead of new ones. I know they are coming from their browser cache but is there any way i can force scripts not to load from cache in server.I am using nginx with php-fpm.
You can force HTTP headers to influence the browser caching behavior, however this is probably not a good idea in a production environment where you want caching.So simply use something like:expires -1To forceCache-Control no-cacheheaderCheck here for more information:http://wiki.nginx.org/HttpHeadersModuleThat being s...
nginx - response based on the requested header
I have nginx 1.0.8 installed. here is my problem: I have 2 files :file1.jsandfile2.js. the requested path is something like this:www.mysite.com/files_dir/%user%/file.jsIf the requested header : "X-Header" exists and has the value "OK" then the responded content should be file1.js else file2.js.The files are situated i...
maplets you define a variable's value based on another variable.mapshould be declared athttplevel (i.e. outside ofserver):map $http_x_header $file_suffix { default "2"; OK "1"; };Then the followinglocationshould do the trick using your new variable$file_suffixlocation ~ ^(/files_dir/.+)\.js$ { root html; t...
how to configure .htc files to work on nginx
I'm trying to run rounded corners on <= IE8 using border-radius.htc locatedhere. I've run the URL to the .htc file in my browser, and I can view the code so my path is correct in the css file. I'm using nginx to host my webpages.Does anyone know how I can get this file to run so that the styling works in < IE9? I've...
I've found the answer,this solution. It's the 2nd post down on the thread.Comment by[email protected], Oct 15, 2009The directives are almost identical if you're using nginx. Open /etc/nginx/mime.types and add the following three lines inside your types {}declaration (in recent versions of nginx they're already there):...
How to serve the right mime type for a blazor site on ubuntu nginx
I have built a blazor webassembly site which I host on an ubuntu server using nginx. The configuration of the site in nginx is like this:server { server_name app.mysite.local; root /srv/sites/app.mysite.local; index index.html; }I published the site using visual studio to a local folder and ...
You don't use the dist folder:You should publish the application usingdotnet publish -c Releaseand copy the folderbin\Release\netstandard2.1\publish\wwwrootto/srv/sites/app.mysite.localThenginx.confshould be:events { } http { include mime.types; types { application/wasm wasm; } server { ...
Nginx/Django File Upload Permissions
Today I noticed that whenever I upload a file through my Django site the file is uploaded with the file permissions 0600 meaning whenever a non root user wants to view the file (nginx) a 403 is shown.This only started happening today from what I can tell. I have checked both the file_upload_permissions and file_upload_...
If you have recently switched to Python 3, please take a look atherefor a reference to octal literals in Python 3. Changing your settings as follows should fix it:FILE_UPLOAD_PERMISSIONS = 0o644Thisis also helpful in writing Python 2-3 compatible code.
Can nginx handle duplicate X-Forwarded-For headers?
When user using proxy (Google data saver etc), the browser adds X-Forwarded-For for clients' real ip address to server. Our load balancer passes all headers + the clients' ip address as X-Forwarded-For header to nginx server. The example request headers:X-Forwarded-For: 1.2.3.4 X-Forwarded-Port: 80 X-Forwarded-Proto: h...
TL;DRnginx:fastcgi_param HTTP_MERGED_X_FORWARDED_FOR $http_x_forwarded_forphp:$_SERVER['HTTP_MERGED_X_FORWARDED_FOR']ExplanationYou can access all http headers withthe$http_variable. When using this variable, nginx will even do header merging for you soCustomHeader: foo CustomHeader: barGets translated to the value:foo...
how to compile nginx with ngx_http_headers_module
I found the reference on how to use thengx_http_headers_modulebut nowhere how to compile Nginx with this module.Any help would be appreciated.
This is a default module. You don't have to do anything to compile it, if you already have compiled nginx with http support.
How to force an HTTPS callback using Microsoft.AspNetCore.Authentication.Google?
I am creating an AspNetCore application with Google authentication. I am deploying this app behind an nginx reverse proxy on an Ubuntu server.Almosteverything is working, but I am having trouble with the callback url.In the Google developer console, I havehttp://localhost:5000/signin-googleset as an authorized redirec...
I finally figured it out.Step 1: Make sure Nginx is sending the necessary forwarding headers, for example:server { # other stuff ... location / { # other stuff ... proxy_set_header X-Forwarded-Proto $scheme; # you could also just hardcode this to https if you only accept https } }Ste...
how to forward http 2 protocol version via proxy?
I have a simple rails application(browser) -> (nginx latest; proxy_pass) -> rails (latest)How do I configure nginx to notify rails that nginx received an HTTP/2 request via a different header IE: my_"http_version = 2.0"? proxy_pass communicates with rails via HTTP 1.1 and I want to know if the original request was ht...
This is similar to what theX-Forwarded-ForandX-Forwarded-Protoheaders are used for, but there not astandard headerused to communicate the HTTP protocol version to the backend. I recommend using this:proxy_set_header X-Forwarded-Proto-Version $http2;The$http2variables comes fromngx_http_v2_modulewhich I presume you are...
How can I have one Kubernetes LoadBalancer balance to multiple services?
I have the following services hosted in my Kubernetes cluster on AWS.An nginx server, on ports 80 and 443.A Minecraft server, at port 25565.Both are working great. I currently have both of them set totype: LoadBalancer, so they both have Elastic Load Balancers that are providing ingress to the cluster.I would like to h...
You could also simply use nginx as a proxy for your minecraft server, and forward traffic from ingress port 25565 to the minecraft server. That way all traffic goes through one Service
Disable SSLv3 on Nginx
Why on my server still enabled SSLv3 ? I want to disable for reasons that in some computers can not open my page because of safety issues.I found thisguide:But currently I've got it set. My server is hosted in Google Cloud, I currently have this Nginx configuration file:... ssl on; ssl_certificate /etc/nginx/dba_certs/...
To disable SSLv3, you'll have to editdefault serverconfiguration, not just an arbitrary virtual host config. It can only be disabled for a listen socket, not just a virtual server. The configuration snippet you've provided suggests that you are using per-server included configuration files, so you'll have to find one w...
Django CSRF Error Casused by Nginx X-Forwarded-host
I've been working on a django app recently and it is finally ready to get deployed to a qa and production environment. Everything worked perfectly locally, but since adding the complexity of the real world deployment I've had a few issues.First my tech stack is a bit complicated. For deployments I am using aws for ever...
Rather than doing an HTTP proxy, I would use Nginx'sbuilt-in capacityto communicate with uWSGI. (This will still work if you are using separate Docker containers for Nginx and uWSGI since the communication is done over TCP)A typical configuration (mine) looks like this:location / { uwsgi_pass http://127.0.0.1:800...
Nginx pass all requests to specific S3 file
I have an S3 bucket with the static contents of my site and I have an EC2 instance that receives all of the traffic to the site.I want to have every request to the EC2 return a specific file from my S3, but I want to keep the URL the same as the user inserted it.Example: Let's assume that my file is located in /path/in...
I ended up using a variable. This solved the problem:server { listen 80; ssl off; location / { proxy_http_version 1.1; proxy_set_header Host 'some-host.s3.amazonaws.com'; proxy_set_header Authorization ''; proxy_hide_header x-amz-id-2; ...
Convert Nginx rewrite from "if" to "try_files"
I have the following NGINX rewrite rule which works great for a PHP script installed in a subfolder:location /subfolder/ { if (!-e $request_filename){ rewrite ^/subfolder/(.*) /subfolder/index.php?do=/$1; } }but Nginx wiki says using "if" is evilhttp://wiki.nginx.org/IfIsEvilso I tried the followinglocation /su...
You want to do the rewrite only if the file doesn't exist, use it as a named location for the fall back intry_fileslocation /subfolder { try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/subfolder/(.*) /subfolder/index.php?do=/$1; }
How to run nginx master process with different user
A/c tohttp://wiki.nginx.org/CoreModule#usermaster process used to run with root user, is it possible to run nginx mater process with different user?
It is possible to run the nginx master process with a different user by just running the init script as non root (i.e./etc/init.d/nginx start).If this is really what you want to do, you will need to ensure the log and pid directories (usually/var/log/nginx&/var/run/nginx.pid) are writable for that user, and all yourlis...
Rails assets missing after Capistrano deploy
I'm building a VPS, and it's deployed via Capistrano, database connected etc, but there are no assets available to the page - it is basic html only.The assets appear to be compiled, and exist in theshareddirectory.From the page html: The asset files appear to exist in theshareddirectory:assay@assaypipeline:~/apps/assay...
Your precompiled assets should reside inpublic/assets, seerails guidesnormally you create them by runningRAILS_ENV=production bundle exec rake assets:precompileas part of your deployment.The shared stuff is to provide old stuff over several deploys.See also thisquestion
Nginx password protect root, and separate password for subdirectory
I'm trying to set up basic HTTP authentication with Nginx that's multi-layered. I'd like to have one username & password for the entire site except for a certain subdirectory (URL), and a separate username & password for that subdirectory. If somebody navigates to that subdirectory, I want them to be prompted for the...
Reference:http://nginx.org/en/docs/http/ngx_http_auth_basic_module.htmlAssume the subdirectory url ishttp://www.example.com/admin/.Step 1: create 2 files storing username/password (encrypted) pairs usinghtpasswd# to secure the admin site htpasswd -bc /tmp/admin_passwd.txt admin adminpassword # to secure the main site h...
Different Domains on Different IP's in Nginx?
I want to use two different domains with different IP addresses, for exampledomain1.com - 12.34.56.78 domain2.com - 98.76.54.32I am usingnginxon Linux OS. What should I add in my nginx.conf?
You have to create twovirtual hostsusingserverblock.Let's suppose/var/wwwcontainsdomain1.comanddomain2.comdirectories with whatever HTML pages, CGI scripts, ...server { listen 12.34.56.78:80; server_name domain1.com index index.html; root /var/www/domain1.com } server { lis...
Which module for Nginx is the best for HTTP PUSH? [closed]
Closed.This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meetStack Overflow guidelines. It is not currently accepting answers.We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-si...
I chose HttpPushStreamModule (https://github.com/wandenberg/nginx-push-stream-module).It's better. It now supports websockets.
Nginx proxy_pass without parameters
http://mydomain.com/=> 127.0.0.1:4567buthttp://mydomain.com/FOO => 127.0.0.1:3000Is that possible?So far I have:upstream myserver { server 127.0.0.1:4567; server 127.0.0.1:4568; } location / { proxy_pass http://myserver; } location /FOO/ { proxy_pass http://127.0.0.1:3000; }But this points tohttp://12...
Ok the problem was pretty simple...I was missing a / at the end of the proxy_pass argumentlocation /FOO/ { proxy_pass http://127.0.0.1:3000/; }
Getting client original ip address with azure aks
I'm currently working on copying AWS EKS cluster to Azure AKS. In our EKS we use external Nginx with proxy protocol to identify the client real IP and check if it is whitelisted in our Nginx.In AWS to do so we added to the Kubernetes service annotationaws-load-balancer-proxy-protocolto support Nginxproxy_protocoldirect...
From the docs:https://learn.microsoft.com/en-us/azure/aks/ingress-basic#create-an-ingress-controllerIf you would like to enable client source IP preservation for requests to containers in your cluster, add--set controller.service.externalTrafficPolicy=Localto the Helm install command. The client source IP is stored in ...
Nginx allow via Domain but not via the IP
This is my configuration:server { listen 80; listen [::]:80; server_name domain.tld www.domain.tld; return 301 https://erp.uni.mk$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name domain.tld; ssl_certificate "/etc/nginx/ssl/ca_full.crt"; ssl_certi...
You need to define a catch all server. Use thedefault_serverparameter on thelistendirective.For example:server { listen 80 default_server; listen 443 ssl default_server; ssl_certificate /path/to/any/cert.pem; ssl_certificate_key /path/to/any/key.pem; return 444; }The server needs a certificate to ...
cert manager is failing with Waiting for dns-01 challenge propagation: Could not determine authoritative nameservers
I have created cert-manager on aks-engine using below command kubectl apply --validate=false -fhttps://github.com/jetstack/cert-manager/releases/download/v0.12.0/cert-manager.yamlmy certificate specissuer specIm using nginx as ingress, I could see txt record in the azure dns zone created my azuredns service principle,...
I ran into the same error... I suspect that it's because I'm using a mix of private and public Azure DNS entries and the record needs to get added to the public entry so letsencrypt can see it, however, cert-manager performs a check that the TXT record is visible before asking letsencrypt to perform the validation... I...
nginx + vueJS + static landing page
I need to open the landing page on/, and vueJS application on/app. Here is my current nginx setup:server { listen 80; location /app { alias /var/www/app/dist/; try_files $uri $uri/ /index.html; } location / { alias /var/www/landing/dist/; try_files $uri ...
I have no idea why, but addinglastto vue application configuration fixed it. Here is how the config looks now:server { listen 80; location /app { alias /var/www/app/dist; # removed the / at the end try_files $uri $uri/ /index.html last; # here is the trick } location / { alias ...
How to reference AWS ACM Certificate when using AWS API to get certificate [duplicate]
This question already has answers here:How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service(4 answers)Closed6 years ago.I am using AWS and I have used ACM to generate a certificate. (This process is different than I am used to where I generate a certificate signing request and give...
You have to use AWS ACM API (IAM certificate and ACM certificate are different). Equivalent API isGetCertificate in ACMaws acm get-certificate --certificate-arn arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012Now, I think you are trying to get the certificate and the chain to use it o...
Kubernetes on GCE: Ingress Timeout Configuration
I'm running Kubernetes on Google Compute Engine (GCE). I have an Ingress set up. Everything works perfectly except when I upload large files, the L7 HTTPS Load Balancer terminates the connection after 30 seconds. I know that I can bump this up manually in the "Backend Service", but I'm wondering if there is a way to do...
This can now be configured within GKE, by using a custom resourceBackendConfig.apiVersion: cloud.google.com/v1beta1 kind: BackendConfig metadata: name: my-bconfig spec: timeoutSec: 60And then configuring yourServiceto use this configuration with an annotation:apiVersion: v1 kind: Service metadata: name: my-servic...