Prompt
stringlengths
14
160
Instruction
stringlengths
18
2k
Response
stringlengths
8
2k
ssl for subdirectory within nginx server configuration
I have a nginx server running with ssl enabled. Currently I have https enabled for all directories. How enable ssl only forwww.example.com/shop/*directory and disable for other??here is my conf file :# Redirect everything to the main site. server { server_name *.example.com; listen 80; ssl on; ssl_certificate ...
It is easy to achieve in Nginx. There are two steps involved in it.Port 443 will be used only when yourdomain.com/shop is accessed. All other requests would be redirected to port 80 (HTTP)Port 80 will check for yourdomain.com/shop. If found, it'd be redirected to port 443 (HTTPS).Here is a quick overview of how it coul...
Is there anyway to make a Rails / Rack application tell the web server to drop the connection
There are many security reasons why one would want to drop an HTTP connection with no response (eg.OWASP's SSL best practices). When these can be detected at the server level then it's no big deal. However, what if you can only detect this condition at the application level?Does Rails, or more generally Rack, have an...
Nginx has a mechanism for this. When you are returning a special status code 444 (it's non-standard), Nginx silently drops the connection. This happens only when you return this code from the Nginx config, i.e. likelocation = /drop { return 444; }and you cannot return this status code from your application. The worka...
website down after installing ssl certificate through certbot in nginx
Below is my nginx configuration. I modified the 'default' file (which is placed at 'sites-available). I am able to access the website when it's through 'http'. But when I try through 'https', there is a connection time out and the page cannot be reached. Nginx is strangely not making any entries to the logs(both access...
443 port opened in aws ec2After two days of never ending debegging, I understood the problem. I had not opened 443 port in EC2 security group. Things to keep in mind whomever struggling with a similar issue -> Ensure that your OS firewall allows connections through 443 also ensure that your instance allows connections ...
nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
I'm trying to setup a server with nginx and docker-compose, but I get these errors every time I try 'docker-compose up':webserver | 2019/06/10 13:04:16 [emerg] 1#1: "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1 webserver | nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf...
This happens when you are trying to overwrite the default nginx config file which does not accept some root properties likehttp,user. If you need those extra configurations you can try copying what you have to/etc/nginx/nginx.confSo instead of this:COPY default.conf /etc/nginx/conf.d/default.confDo this:COPY nginx.conf...
nginx: [alert] kill(57200, 1) failed (3: No such process)
When I am executing this command:./nginx -s reloadThrow error:nginx: [alert] kill(57200, 1) failed (3: No such process)when I open the nginx.pid file:vim /usr/loca/nginx/logs/nginx.pidthe process id is:57200.But when I am checking nginx process,it does not have master process,the output is:[root@localhost logs]# ps -au...
I also faced similar issue on nginx 1.10.2.Instead of./nginx -s reload, I used./nginxto start nginx and it solved this issue.
Nginx Restrict Access to File
Currently my config file (/etc/nginx/sites-available/default) saysserver { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location /credential...
Try adding a=to your location, that will do an exact match:server { server_name _; listen 80 default_server; location = /credentials.js { deny all; return 404; } location / { add_header Content-Type text/plain; return 200 "hello world\n\n"; } }From thenginx loca...
The header sent by Postman is not received in the PHP script
I am sending a header along with a GET request to a PHP script but either Postman does not send the header or the PHP script does not receive it. I am using Nginx for the server (Apache2 gave almost the same result with api_token absent). I am not able to find what is wrong.The server side PHP code is as follows:$val){...
I don’t think that you can use an underscore in the header name of a custom header as it’s a feature that’s disabled by default. More information can be foundhereYou could test this out by removing this from the header name.
Setting up proxy_pass on nginx to make API calls to API Gateway
Problem:I've set up a Lambda function behind API gateway which works beautifully. I have a hosted site that I want only a certain location to hit the API.Examplehttps://www.example.com/(Serves up html from hosted server)https://www.example.com/foobar(Returns a JSON payload that is generated by Lambda and returned by AW...
I think you need those two lines:proxy_set_header Host "XXXXXX.execute-api.REGION.amazonaws.com"; proxy_ssl_server_name on;Here is the explanation about the why:TheHOSTheader is required as is describedhereThe Amazon API Gateway endpoint. This value must be one of the region-dependent endpoints listed underRegions and ...
nginx redirect subdomain to seperate server ip
I have a dynamic IP which I manage using ddclient. I use no-ip to maintain the hostnames to point to my IP.I have www.somename.com, sub.somename.com and app.somename.com. Obviously, these all point to my IP. The first two are a couple of wordpress pages on a server (server1) running NGINX, with separate configs in site...
You could try like this!server { server_name app.somename.com; location / { proxy_pass http://192.168.0.16:80; proxy_set_header Host app.somename.com; } }
Expires in nginx.conf throws error on ubuntu but not on OSX
My nginx.conf is working on local (OSX) but throwing an error on prod (Ubuntu)The full file:https://github.com/thomasdane/partywave/blob/master/nginx.confBut the relevant part is:# Expires map map $sent_http_content_type $expires { default off; text/html 1w; text/css ...
What version of nginx do you have in ubuntu? If you have 14.04 with default repo, it is1.4.6. And expires accepts variables only since1.7.9. You can add nginxofficial repoand install 1.10 from it. Semi-automatic installation:apt-get install -y lsb-release LIST="/etc/apt/sources.list.d/nginx.list"; OS=`lsb_release -si |...
PHPMailer : replace the default messageID
I send emails using PHPMailer, evthg works well but I would to set a uniq MessageID for each email.PHPMailer version : "v5.2.16"(loaded with Composer fromhttps://github.com/PHPMailer/PHPMailer.git)I found the documentation here :http://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#property_MessageIDso here is wh...
The structure ofMessageIDshould be:If yourMessageIDdoesn't have this exact structure - PHPMailer will ignore yourMessageIdand generate it's own MessageId.You can change your code to:$mail->MessageID = "<" . md5('HELLO'.(idate("U")-1000000000).uniqid()).'-'.$type.'-'.$id.'@domain.com>';And it should work.
Polymer Starter Kit - Pretty URLS on Nginx Server
the Polymer Starter Kit (PSK) contains instructions on using Pretty URLs when hosting on FirebaseHEREI am attempting to do similar using Nginx Server, but cannot figure out the Location Block for page reloads. Using the sample data that comes with PSK, how would you configure "/users/sam", for example.
nginx configserver { listen 80; server_name example.com; root /home/myuser/psk/dist; index index.html; location / { try_files $uri /index.html; } }Make sure to add abase urlto yourindex.html. In case of Polymer starter kit & nginx the base element will help direct access to URLs with query parameters...
Escaping dollar sign when echo write to file in CentOS linux bash script
I am working on a bash script that needs to create a file in this location:/etc/yum.repos.d/nginx.repowith the following contents:[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1So, I have tried to do it like this:cat >/etc/yum.repos.d/nginx.repo <<EOL [nginx]...
In principle, it suffices to use a syntaxcat >file <<EOL $my_var EOLThat is, use the vars as they are, without escaping$.So instead ofbaseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/ ^ ^saybaseurl=http://nginx.org/packages/centos/$releasever/$basearch...
How do I redirect www traffic without triggering browsers SSL check?
I have a valid certificate for example.com. If users go to my site athttp://example.com, they get redirected tohttps://example.comand all is good. If they go tohttps://example.com, all is good. If they even go tohttp://www.example.com, they get redirected tohttps://example.comand all is good.However, if they go tohttps...
If your certificate is for example.com only and not for www.example.com then any access to www.example.com will trigger a certificate warning, no matter if you want just redirect it or not. Redirection is done at the HTTP level and before it talks HTTP it first does the SSL handshake (which triggers the problem), becau...
Gitlab Omnibus: how to redirect all requests to another domain
I migrated my Gitlab to a new domain. I'd like to redirect all HTTP requests from the old URL to the new one. Both domains currently point to the same server (usingADNS records).I use Gitlab Omnibus package, with the bundled nginx install. How to do this?
First, create/etc/nginx/conf.d/redirect.conf:server { listen 80; server_name old-gitlab.mydomain.com; rewrite ^/(.*)$ http://new-gitlab.mydomain.com/$1 permanent; }(if the/etc/nginx/conf.d/path does not exist, go ahead and create it)Now edit the configuration file at/etc/gitlab/gitlab.rbto add the following line:...
How can I run my docker container with installed Nginx?
I have docker image withDockerfile, that successfully build withdocker build .command. TheDockerfilecontent is:FROM ubuntu RUN apt-get update && apt-get install -y nginx php5 php5-fpm ADD . /codeHow can I run my docker container to see thatNginxis work?UPDATE: When I try to use next Dockerfile:FROM ubuntu RUN apt-get u...
When you build the image you probably want to specify the image name with-toption.docker build -t my/nginx .To run a container use theruncommanddocker run --rm -ti my/nginxYou probably should add the following command to your DockerfileCMD ["nginx"]Or with php5-fpmCMD service php5-fpm start && nginxUPDATE. You should r...
HHVM + NGinx Connection refused
I'm trying to install HHVM on Debian 7 by prebuilt package. I've another server with the same configuration and it's working but in one of the servers HHVM FastCGI refuses the connectionIt's /var/log/nginx/error.log2014/11/25 23:24:10 [error] 422#0: *39 connect() failed (111: Connection refused) while connecting to ups...
I just realized the problem by myself.HHVM with its default setting without specifying the IP to listen, was only listening ipv6 addresses. Because of that i could connect with localhost but not with 127.0.0.1Specifying the IP by hhvm.server.ip = 127.0.0.1 solved the problem.
Does os.execute block thread in lua?
In my nginx+lua app OS executing a command line something likeos.execute("ls 2>&1 | tee a.txt")I want to know does it block main app? I want use command "execute-and-forgot" case. If it blocks how to fix it and execute a simple line in background thread?
os.execute() will block for the time of execution of the command you are running and since you generate some output, usingio.popenwon't help you much as you'd need to read from the pipe (otherwise the process will still block at some point).A better way may be torun the process in the background:os.execute("ls >a.txt 2...
Graphite nginx requests per second
Is there any way how to get Graphite to graph req/s ?When you retrieve nginx requests from nginx_status you are sending an absolute value to the graphite, so I'm thinking if there is any way how you can get the rate per second ?My understanding is thatderivative(series)would give you requests/minute but I could really ...
I'm not sure if this is the right way to do this but it seems like this did the trickscaleToSeconds(derivative(stats.*.*.*.nginx.handles),1)Anyone sees any problems with this ?
Why can't nginx find my assets?
I'm on rails 3.2 and my production setup is using nginx and unicorn.I have a problem with some assets that a ruby gem called sidekiq uses. However those assets are not being served properly when I request them. My nginx config looks like this:upstream unicorn { server unix:/tmp/unicorn.myapp.sock fail_timeout=0; } s...
Solved it, It was all due to a wrong setup in my production.rb in rails, which made the default behavior fail, so the hack of putting the assets into /public manually isn't necessary anyways.I had:config.action_dispatch.x_sendfile_header = "X-Sendfile"Which instead for nginx should be:config.action_dispatch.x_sendfile_...
running multiple rails websites using phusion passenger 3.0.17 with nginx
I searched google for deploying multiple rails websites using phusion passenger 3.0.17 with nginx but I didn't get relevant results. Any how I completed passenger nginx setup by running passenger-install-nginx-module command.Ques 1)I am looking for proper beginner tutorial for running multiple rails websites using phu...
According to the documentation for Passenger, you create a new vhost for each app you want to deploy. And point the siterootat your apps public directory, and add thepassenger_enableddirective. Exactly the same as deploying with Apache.http { ... server { listen 80; server_name www.mycook.com; ...
One rails application for multiple domain names
I have one rails application needed to be deployed by passenger module nginx. This application needs to be served for hundred domain names. I don't have enough memory to launch hundred rails instances. I'm not sure the proper way to launch rails in few instances. It's the same application under different domain names.s...
Just set up multiple domain aliases for that server entry.server { listen 80; server_name www.a_domain.com www.b_domain.com www.c_domain.com; root /webapps/mycook/public; passenger_enabled on; }That'll serve requests to each of those domains, and all hit the same app pool.
Enabling QUIC / http/3 on multiple domains with NGINX 1.25
NGINX 1.25 introduced support for http/3 (over QUIC).To enable it, one can addlisten 443 quic reuseport;to theserverblock, alongside the likely existinglisten 443 ssl http2;However, if I add thequiclisten for more than one server block (which all have a differentserver_nameset), then NGINX rejects the config with the f...
Yes, nginx can serve http/3 on multiple virtual hosts, butreuseportoption is supported only for 1 virtual host per the samelisten IP:PORTdirective.So, you should use different IPs for your virtual hosts or removereuseportoption.
What does ssl_verify_depth mean in nginx.conf?
I am wondering what does ssl_verify_depth mean in nginx.conf? Thedocsare not very detailed, there is just this sentece:Sets the verification depth in the client certificates chain.What does increasing or decreasing do? I've noticed that increasing it makes nginx more likely to accept the cert, but why is that?
The depth actually is the maximum number of intermediate certificate issuers, i.e. the number of CA certificates which are max allowed to be followed while verifying the client certificate.A depth of 0 means that self-signed client certificates are accepted only, the default depth of 1 means the client certificate can ...
Nginx using CORS with credentials
I'm working on building a web application that communicates with a Laravell API through an Nginx server. I tried following the directions on the Nginx website forwide open cors, but it doesn't like the wild card response when sending credentials.Access to fetch at 'https://api.***.com/' from origin 'http://localhost:80...
The error message is right, you can't use a wildcard originandcredentials:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-OriginFor requestswithout credentials, the literal value "*" can be specified, as a wildcard; the value tells browsers to allow requesting code from any origin to acce...
Removing 'server' header from response header of Nginx version 1.18 in Ubuntu 20.04
I could not able to remove 'Server' header from response header of Nginx version 1.18 in Ubuntu 20.04 OS.I have done the following steps:sudo apt-get updateInstalled nginx-extras by using command 'sudo apt-get install nginx-extras'Added the code snippet 'more_clear_headers Server;' in http section of nginx.conf file.Af...
You should load the 'ngx_http_headers_more_filter_module.so' by adding the below code snippet in nginx.conf file.load_module modules/ngx_http_headers_more_filter_module.so;It will work.Cheers!
Unable to COPY config file in nginix /etc/nginx/conf.d/default.conf
Unable to Copy config file in my project dir to /etc/nginx/conf.d/default.confsource file location: /app/nginix.confCOPY nginx.conf /etc/nginx/conf.d/default.confdestination : /etc/nginx/conf.d/default.confSteps in docker file :Tried the multi stage build: - FROM node:8.9.0 as buid - WORKDIR /app - COPY package.json ...
If the source file path is/app/nginix.confthen dockefile should contain:COPY /app/nginx.conf /etc/nginx/conf.d/default.confIf you're runningdocker buildcommand from/appdirectory on your host then your above dockerfile should work.Update:If you're expecting /app/nginx.conf file ofnodedocker image to present innginx:alpi...
Make links in response relative to new path
How do I redirect all myhrefswithin my response to hit my new path. For e.g., my ingress file isapiVersion: extensions/v1beta1 kind: Ingress metadata: name: ingress-odin annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1 spec: rules: - http: paths: - path: /odin/?(.*) back...
Even if you fix the thesub_filterconfiguration snippet by includingsub_filter_once on;as suggested in the other answer it will not work, because thebasetag works only with relative paths (see:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).Theapp-rootsolution is technically correct, but boils down to th...
How to configure Port Forwarding with Google Cloud Compute Engine for a Node.JS application
I'm trying to configure a port forwarding (port 80 to port 8080) for a Node.js application hosted on Google Cloud Compute Engine (Ubuntu and Nginx).My ultimate goal is to have an url like "api.domain.com" showing exactly the same thing from "api.domain.com:8080" (:8080 is working actually).But because it's a virtual se...
One possibility is to use Google Cloud Load balancer.https://cloud.google.com/load-balancing/docs/1) Create a backend service that listen on port 80802) Create a frontend service that listen on port 803) Then forward frontend trafic on this backend service4) Bonus : You can create a ssl certificate auto managed by GCPh...
Nginx upstream failure configuration file
I'm trying to start up my node service on my nginx webserver but I keep getting this error when I try to do nginx -tnginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/nginx.conf:3 nginx: configuration file /etc/nginx/nginx.conf test failedMy current nginx.conf is like this:upstream backend { serv...
tldr; Theupstreamdirective must be embedded inside anhttpblock.nginx configuration files usually haveeventsandhttpblocks at the top-most level, and thenserver,upstream, and other directives nested insidehttp. Something like this:events { worker_connections 768; } http { upstream foo { server localhost:...
Nginx / PHP-FPM 504 Gateway Timeout
I am using php-fpm with nginx. I have scripts which take an uploaded excel sheet and process it. This is a long running job. However, after 60 seconds of execution time I get a 504 Gateway Timeout error.The php script keeps running to completion. So nothing is stopping the script from completing.I need to stop this err...
I almost completely gave up on this! However at the last minute I came up with the answer.The servers are on Amazon AWS behind a load balancer. The load balancer had the idle-timeout attribute set at 60 seconds. Changing this setting fixed the problem!!
Is it possible to set up nginx without cookies?
I see, especially here in Germany, more and mor web sites, asking for permission to set cookies. My current project doesn't require cookies on the application level. So I am wondering if i shouldn't drop cookies entirely.My questions:Is it possible to set up static web site with nginx entirely without the use of cookie...
Yes, it is certainly possible.There are absolutely no downsides° (°unless you care for tracking, user-login, or having any sort of preferences, although alternatives exist as well).On the other hand, there are plenty of upsides — you ensure that if one user shared the URL with another one, that the URL will work as exp...
How can my s3 bucket host multiple websites in different folders using nginx?
I have an s3+Cloudfront solution on Amazon. I would like to host different websites in different folders inside the bucket and access them in one of this two way: - a subdomain -> mywebsite1.mydomain.com or - path -> www.mydomain.com/mywebsite1I read that a proxy based on nginx could solve my problems. Is it true? Is i...
You can do this with Nginx (or HAProxy) running in EC2 and acting as a reverse proxy in front of the buckets, yes, but if you are not already familiar with how to configure it, it may be simpler to just use CloudFront... a second time.The solution here is to create a separate distribution each web site subdomain.Assumi...
Git clone through Nginx proxy for Gitlab server is not working
My Nginx Server is acting as a proxy for a Gitlab Server, the problem is when I try "**git clone[email protected]:username/project.git**" I'm unable to clone the project [it is not tunneling from Nginx server to Gitlab server]When I update my local system's /etc/hosts file with IP Address of Gitlab Server then it clone...
First, you need to stop having Nginx listen on port 22. Nginx doesn't handle SSH forwarding, your firewall does.If you're using iptables, then these rules will forward all requests through your Nginx host to your Gitlab host.sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -j DNAT --to-destination [GITLAB-I...
Heroku Local: "http" directive is duplicate
I'm running into the following issue when runningheroku local:[emerg] 595#0: "http" directive is duplicate in /usr/local/etc/nginx/nginx.conf:17I've gotheroku/heroku-buildpack-php": "*"in my composer.json, and a fresh install of nginx (usingbrew install nginx)Could someone explain to me what could be happening?
So it seems the problem is related to theheroku.confgenerated by$root/vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.phpHeroku localruns nginx withnginx: master process nginx -g daemon off; include $root/vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf;So both/usr/local/etc/nginx/nginx.confandheroku...
Symfony server:run error
I'm getting this error when I'am trying to runmyproject, symfony2 project. I think that the error came up because on that port8000I haveajentiserver running withnginx.Server running on http://127.0.0.1:8000 Quit the server with CONTROL-C. RUN '/usr/bin/php5' '-S' '127.0.0.1:8000' '/srv/myproject/vendor/symfony/symf...
use the command like this:php app/console server:run 127.0.0.1:8080to run the server on port 8080 or change the port to your own preference
Rails application behind proxy, with SSL, renders paths as "http://"
To start with, this sounds more like a bug then anything else.My rails application is served by Unicorn. Then, using Nginx as a reverse proxy, I serve the application to the outside world using SSL.So far so good, no problem. I'm using relative paths (Restful path helpers), so there should be no problem to produce this...
So far, I've managed to get a workaround by adding a rewrite rule to Nginx, under plain http:rewrite ^/(.*)$ https://www.example.com/$1? permanent;Which redirects all plainhttprequests to thehttpsserver.Update:Apparently, as I want the app not to care about how the front web server is serving it, it's up to the same w...
Stream music with byte range requests with Django + nginx
I am building a music player application with Django + nginx for which I need a backend which supports byte range requests.Django is authenticating the media file correctly but django dev server does not support range requests (206 partial response). Nginx directly serves byte range requests after usingthis configurati...
response = HttpResponse(content_type = mimetype, status=206) response['Content-Disposition'] = "attachment; filename=%s" % \ (fileModel.FileName) response['Accept-Ranges'] = 'bytes' response['X-Accel-Redirect'] = settings.MEDIA_URL + '/' + fileModel.FileData.MD5 response['X-Acce...
non www to www using AWS Elastic Load balancer and Nginx
I have an app running on example.com and now I wanna redirect all the traffic to the www.example.com since we are collaborating with Akamai's CDN for your website. My domain is parked in Route53, added the CNAME of Elastic Load Balancer's CNAME to pointing to *.example.com and I am running nginx web server with the fol...
I had the same issue with the redirect (using same nginx conf code as shown here).Then, I put my redirect configs as the last server{} block (at the end of my domain.com config file), and the ELB was able to find the instances again.I have not looked more into it, but it seems that vhost processing is done in order, so...
When PHP Fatal error happens, Nginx reports HTTP Error 500 to browser
My server is setup with Nginx + PHP + FastCGI. Whenever PHP throws a Fatal error, it gets logged inside of nginx/error.log, but the server reports HTTP Error 500 back to the browser instead of displaying the PHP Fatal error to the browser as is desired and typical in other setups. I've been searching for how to resolve...
Found it!As of PHP 5.2.4, the default is now to cause a 500 error, because the alternative is an empty page.Other discussionssuggest that this behavior can not be changed for the "PHP Fatal" error type, which don't flow through the normal error handler routines and can not be caught or stopped.
Tricking a Rails App to think it's on a different port
I have a Rails app that is running on port8080that I need to trick to think it's running on port 80.I am running Varnish on port80and forwarding requests to nginx on port8080, but when the user tries to login with OmniAuth and the Devise gem generates a url to redirect back to the server, it thinks its on port 8080 whi...
I have the same setup with Varnish on port 80 and nginx on port 8080 and OmniAuth (no Devise) was doing exactly the same thing. I tried settingX-Forwarded-Portetc in Varnish andfastcgi_param SERVER_PORT 80;in nginx, both without success. The other piece in my setup is Passenger (which you didn't mention) but if you are...
nginx fails to start [closed]
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be about programming within the scope defined in thehelp center.Closed10 years ago.Improve this questionWe are running into the following error when we try to start Nginx (on Ubuntu) "" St...
The problem here is probably that you a something likeaccess_log on;in one of your config-files. Just changeonto thepath/to/your/logfile:)
Can I block request by Cookie value in Nginx?
I want to block exact cookie value like PHPSESSID in Nginx. Does this possible? My site under DDoS but I can't block by IP due to shared addresses. Attackers use same value of Cookies so I try to block by cookie value.Thanks
server { ... if ($cookie_PHPSESSID = "XXXXXXXXXXXX") { return 403; } }
Django admin interface missing css styling in production
The user interface is working well, and all CSS styling and static files are served correctly, but the admin interface is missing CSS styling. I looked at similar posts but in those posts people had the issue with both the user and the admin interface. My issue is only with the admin interface.Please see my static file...
Could you please try below steps and let me know if it's working or not?Apply below changes in settings.py file:STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static')Remove below line from your settings.py:STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]Execute below command in production:python ...
how to add cache control header with proxy pass in nginx for some file extensions
I like add cache control header with nginx for some extensions such as .jpg, etc but so far some of the solutions I found on the net, I couldn't get it to work. I will tell you what I have tried.I have tried variations of the following in different place in the .conf file of my site and when I tried the site become bla...
Use themapdirective:map $cache $control { 1 "public, no-transform"; } map $cache $expires { 1 1d; default off; # or some other default value } map $uri $cache { ~*\.(js|css|png|jpe?g|gif|ico)$ 1; } server { ... expires $expires; add_header Cache-Control $control; ... }(...
How do I allow secure remote connections to a local MySQL database using Nginx?
Opening the default port 3306 to the outside world is something I would like to avoid if possible. We have Nginx running for reverse proxy purposes for other applications. The goal here is to access the MySQL databases with clients such as MySQL Workbench from outside the local network, in a secure way. The MySQL serve...
The goal here is to access the MySQL databases with clients such as MySQL Workbench from outside the local networkAll modern MySQL GUI clients support SSH tunneling. This is the most secure approach to connect and requires zero configuration on the server-side: if you can connect via SSH, then you can connect to MySQL ...
I want to deploy back-end and front-end seperate apps on the same server with nginx
I've created a restful api with nodejs and I'm planning to use sapper/svelte for front-end. In the end, these will be seperate apps and I want to run them on the same server with same domain. Is this approach reasonable? If it is, what should my nginx configuration file look like? If not, what should be my approach?Thi...
Following best pratice your API will be under BASE/api/That will allow you to host backend + Frontend on the same serverserver { server_name domain.name; location /api/ { # Backend proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; ...
Cant connect Browsersync with DDEV nginx server, because SSL Error
I'm running DDEV nginx server on Bedrock wordpress site and trying to load snippet for Browsersync.gulpfile.js browserSync task:browserSync.init({ proxy: { target: "https://web.ddev.site" }, https: { key: "/Users/user/Library/Application Support/mkcert/rootCA-key.pem", cert: "/Users/user/Library/Application Support...
The problem was bad ssl certificates file. It was necessary to use docker container certificate. Proxy option is not anymore required.After setup ddev container, you need to copy docker certificate to some location:docker cp ddev-router:/etc/nginx/certs ~/tmpAfter that just update path to correct certificates files. My...
Nginx multiple instances
I have an EC2 instance with AWS and I have installed nginx and created multiple server blocks to server multiple applications.However, if nginx goes down, all the applications go down as well.Is there any way to setup seperate nginx instance for each application? So if one nginx instance goes down, it won't affect othe...
Yes, its technically possible to install 2 nginx instances on the same server but I would do it another way.1 - You could just create multiple EC2 instances. The downside of this approach is that maybe it's gets harder to maintain depending on how many instances you want.2 - You could useDockeror any of its alternative...
nginx: Remove "Server" response header - not honour what said in doco
Nginx version: 1.15.8According to nginx doc:http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens:"starting from version 1.9.13 the signature on error pages and the “Server” response header field value can be set explicitly using the string with variables. An empty string disables the emission of the “S...
Additionally, as part of ourcommercial subscription, starting from version 1.9.13 the signature on error pages and the “Server” response header field value can be set explicitly using the string with variables. An empty string disables the emission of the “Server” field.Source:http://nginx.org/en/docs/http/ngx_http_cor...
Use Environment Variable or Parameter in nginx.conf
I try to add a proxy_pass in the nginx.conf likelocation /example/ { proxy_pass http://example.com; }But instead of hard codinghttp://example.comin the conf file I want to have this value in an environment variable.How can I use environment variables in nginx.conf? Or is there a better way with nginx no have exte...
If you want pure environment variables into nginx config, you will need implements some code in Lua Language:https://blog.doismellburning.co.uk/environment-variables-in-nginx-config/If you don't have a high load on this NGinx, I recommend implements this above solution.In my specific case, to reduce CPU load, I prefer ...
Laravel project's all assets are giving 404 error
I am developing a Laravel project. It is under 5.7 Laravel version. I am using Homestead as a local development environment. When I run any route in the project, it doesn't load public assets. instead, it gives 404 error. see attached image below.I coded correctly on getting assets path{{ asset("public/js/frontend/jque...
As suggested by @Douwe de Haan you don't have to use the public part, just call{{ asset("js/frontend/jquery.min.js") }}
Aurelia, Docker, Nginx, AWS Elastic Beanstalk Showing 502 Bad Gateway
I've deployed an Aurelia application to AWS Elastic Beanstalk via AWS ECR and have run into some difficulty. The docker container, when run locally, works perfectly (see below for Dockerfile).FROM nginx:1.15.8-alpine COPY dist /usr/share/nginx/htmlThe deployment works quite well, however when I navigate to the AWS pro...
It has nothing to do with your aurelia application. You are missingEXPOSEstatement (which is mandatory) in yourDockerfile. You can change it like this.FROM nginx:1.15.8-alpine EXPOSE 80 COPY dist /usr/share/nginx/htmlIf you try to run it withoutEXPOSE, you will get an errorERROR: ValidationError - The Dockerfile must...
Twitter: "Fetching the page failed because other errors", on Forge NGINX server with SSL
Our website is running on Laravel Forge with 'Let's encrypt SSL,' and HTTPS is OK in the browser. We added FB, Twitter meta tags for having branded FB and Twitter cards when sharing on these media.Following 'ERROR: Fetching the page failed because of other errors. ' is raised when trying to display Twitter card in twee...
I've lost the better half of a day on this issue, likely digging through the same threads as you. This thread held the answer:https://twittercommunity.com/t/twitter-card-error-fetching-the-page-failed-because-other-errors/112895/6Enabling AES128 as an ssl cipher will allow the Twitterbot to connect. This can be done ...
Nginx: limit_conn vs upstream max_conns (in location context)
Environment: Nginx 1.14.0 (seedockerfilefor more details).To limit the number of concurrent connections for a specific locationin a server, one can use two methods -limit_conn (third example for all ips)andupstream max_conns.Is there a difference in the way the two methods works?Can someone explain or refer to explanat...
upstream max_connsis the number of connections from thenginxserver to an upstream proxy server.max_connsis more to make sure backend servers do not get overloaded. Say you have an upstream of 5 servers thatnginxcan send to. Maybe one is underpowered so you limit the total number of connections to it to keep from overlo...
How to determine the IP ranges used by the GCP load balancers
How to determine the IP ranges used by the GCP load balancersI am operating several VM instances on Google Cloud Platform (GCP). They are behind an HTTP(S) load balancer.In order to restrict the access based on the origin IP address, I configured the Nginx on each VM instance as follows:server { listen 80; listen [...
I ran into this exact same issue while testing a deployment on Google Kubernetes Engine. I found out that if you assign a static IP address to your load balancer, that is the additional IP address that traffic will be forwarded from. Static IP addresses are always out of the listed range for Google's load balancers sin...
Unable to uninstall nginx on Mac OS X
Output ofnginx -v:nginx version: nginx/1.14.0.After runningbrew uninstall nginxorbrew remove nginx, it gives error:Error: No such keg: /usr/local/Cellar/nginxI have tried :rm -f /usr/local/sbin/nginx rm -f -R /usr/local/etc/nginx rm -r /usr/local/opt/nginxBut stillnginx -vgiving output:nginx version: nginx/1.14.0How ca...
Check path withwhich nginxThen, you can remove from that path.
Nginx missing trailing slash returns 301
I have the following config:server { listen 80; server_name localhost; location /app { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /app/index.html?$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/ht...
The$uri/term in thetry_filesstatement causesnginxto append a trailing/to the requested URI, if that URI resolves to a local directory. Seethis documentfor more.The trailing/is appended by issuing a 3xx response, and of coursenginxgets the port wrong as it knows nothing about port 8000.If you do not wantnginxto issue an...
Why is the connection reset when uploading Wordpress plugin or theme on Ubuntu
System OS:DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTSI have installed a LEMP stack:nginx/1.10.0 (Ubuntu) MySQL 5.7.18-0ubuntu0.16.04.1 PHP 7.0.15-0ubuntu0.16.04.4The system is hanging and displaying a 'connection reset' error message in the browser when I try ...
I have the same problem and solve it by editing my htaccess, and it looks like this:# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress # WP Maximum Execution ...
Running Apache Zeppelin with nginx as reverse proxy
In our current architecture we have two apache front servers, in front of them, we have an nginx load balancer. And in front of that an nginx reverse proxy.My problem is that i'm trying to run Apache Zeppelin through the reverse proxy, and i'm having some problems with the websockets.I get an error like this :400 HTTP ...
you can add to your reverse proxy configurationlocation /ws { # For websocket support proxy_pass http://zeppelin:8080/ws; proxy_http_version 1.1; proxy_set_header Upgrade websocket; proxy_set_header Connection upgrade; proxy_read_timeout 86400; }Reference:Zeppelin 0.7 auth docs
Call to undefined function bzdecompress PHP
I have an Ubuntu 16.04 server with PHP7 + nginx running. I already have a project in PHP Laravel 5.1 running in my local enviroment (Windows with Xampp) and everything is running great. I have a PHP script that uses the functionbzdecompressofBzip2but then, in the server just crash and show this message:Call to undefine...
1)check your installed packagesphp -mif bzip2 is installed move to step3directly , if not installed then install it by running :2)for php7 :apt-get install php7.0-bz2for php5:apt-get install php-bz23)then make sure that you've enabled your extension via :phpenmod bz24)then you can restart your serverservice nginx resta...
PHP Warning: Unable to load dynamic library '/usr/lib64/php/modules/solr.so' undefined symbol: php_json_decode_ex in Unknown on line 0
After success install I'm getting the below errorNOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/solr.so' - /usr/lib64/php/modules/solr.so: undefined symbol: php_json_decode_ex in Unknown on line 0can any one help me out in this Issue ?my server details are as:-php...
After doing a lot of experiments I finally fixed the issue. The solution is as below:cd /etc/php.d/And create a file namedsolr.ini.Added this line:extension=solr.soAnd now I have to remove the above extension from thephp.inifile and restartphp-fpmThat's all, worked for me.
Stale-while-revalidate cache replacement from Varnish
We are currently moving our servers to a new one, with PLESK 12.5 which doesn't support Varnish cache for our PHP applications.We use Varnish, mostly for the 'stale-while-revalidate' capability, so that we can send whole pages or parts (using ESI) without any waiting time for any customer while cache is refreshing.Is t...
Actually nginx provides stale-while-revalidate byproxy_cache_use_staleandNginx supports Cache-Control extensions since 1.11.10:location / { ... proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504; proxy_cache_background_update on; }Yes, it does not support Cache-Control extensio...
How to log the real client IP on embedded Tomcat access log on Spring Boot application with Nginx as reverse proxy?
I have Nginx in front of a Spring Boot 1.3.3 application with Tomcat access log enabled, but the logging always write the proxy IP address (127.0.0.1) instead of the real client IP.Is the X-Real-IP header used to get the real client IP?Is this header used by tomcat to write the IP address in the access log?I have this ...
The real client IP is available in$proxy_add_x_forwarded_forvariable i.e.X-Forwarded-Forheader. It will have "," separated entries. The very first value is the real client IP.To log the real client IP in Tomcat's access logs, modify the pattern value in the AccessLog Valve as:%{X-Forwarded-For}i %l %u %t "%r" %s %b
nginx proxy_pass is setting port in response
I have an Nginx config similar to:server { listen 80; listen 443; server_name api.mysite.dev; location / { proxy_set_header Host "api.mysite.dev"; proxy_set_header X-Real-IP $remote_addr; proxy_pass $scheme://127.0.0.1:8001; } } server { listen 80; listen 443; ...
You have to set the following options:proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host;This is a sample that works:server { listen 80; listen 443; server_name api.mysite.dev; location /api/ { proxy_pass http://127.0.0.1:800...
Go web server with nginx server in web application [duplicate]
This question already has answers here:What are the benefits of using Nginx in front of a webserver for Go?(4 answers)Closed8 years ago.Sorry, I cannot find this answer from Google search and nobody seems to explain clearly the difference between pure Go webserver and nginx reverse proxy. Everybody seems to use nginx i...
There's nothing stopping you from serving requests from Go directly.On the other hand, there are some features that nginx provides out-of-the box that may be useful, for example:handle many virtual servers (e.g. have go respond onapp.example.comand a different app onwww.example.com)http basic auth in some paths, say ww...
Nginx connect() to unix:/var/run/fcgiwrap.socket failed
I'm trying to install Gitweb on my Nginx server. Everything seems to be configured correctly, but I seem to be getting the following error in the gitweb.log:`2015/06/08 08:42:05 [crit] 29135#0: *5 connect() to unix:/var/run/fcgiwrap.socket failed (13: Permission denied) while connecting to upstream, client: 83.36.85.6...
The socket has to be readable and writable by both client and server. Under the assumption that the server is running aswww-dataand the client is running asforgewith groupforge, the following steps should fix the issue.Change the group ownership of the socket to the group of userforge.chgrp forge /var/run/fcgiwrap.sock...
Docker: Nginx & PHP Container: no such file or directory
I want to play around with docker so I created my own 2 container, nginx and php. Both container are build successfully and are published on docker hub. After that I created a fig.yml in my projects folder. If I runfig up -din my terminal, then I got the following error:Recreating playground_php_1... Cannot start conta...
The underlyingphp:fpmimage has the following line in theDockerfile:WORKDIR /var/www/htmlYou then delete this directory, which breaks the defaultCMDcommand as it usesWORKDIRas its base.I don't know much about PHP and this Docker image, but it's worth reading the documentation and looking at any examples you can find on ...
nginx location regex, match multiple times
How to match multiple times in nginx location regex ?it seems the {x,x} syntax never works!for example:location ~ ^/abc/\w{1,3}$ { ... }nerver work!
You must quote location which contains{or;characters.location ~ "^/abc/\w{1,3}$" { ... }otherwise nginx parse it aslocation ~ ^/abc/\w { 1, ...and fails with syntax error.
PHP-FPM breaks up stack trace log into separate events
I have a problem with PHP-FPM registering a single event as multiple events. Take for example the stack trace below:[30-Jul-2014 05:38:50] WARNING: [pool www] child 11606 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'new-layout.mobile.phtml' not...
Unfortunately notPHP-FPM simply logs each line of PHP output as a separate event. There's nothing you can do in/with PHP-FPM to change this.PHP CodeYou'll need to "fix" this in your application (PHP code). There are 3 ways you can influence the way PHP reports errors, and you'll probably want to use all 3:Register a cu...
Django Internal Server Error instead of 404
I am using Django 1.6, uwsgi and nginx, the application works fine but I am getting 500 error and the email below for every invalid URL that I am trying to access, instead of a 404 error.I get this forhttp://my_project_url.com/whateveror even forhttp://my_project_url.com/favicon.icoI have looked over the URL's but ther...
It seemsyou have a custom processor trying to resolve path:File "./project/context_processors.py", line 88, in app_delegate app_name = resolve(request.path).app_nameQuoting djangoresolve()docs:If the URL does not resolve, the function raises a Resolver404 exception (a subclass of Http404) .I suggest to you tomanage e...
nginx virtual host: php5-fpm-sock error
I am trying to set a virtual host for a fresh ubuntu/php5.5/nginx installation as suchetc/nginx/sites_available/mydomain.com :server { listen 80 default_server; root /home/www/mydomain.com/public/; index index.php index.html access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; server_name mydom...
The fpm adress path was missing:nano /etc/nginx/conf.d/php5-fpm.confedit :upstream php5-fpm-sock { server unix:/var/run/php5-fpm.sock; }
Plesk nginx config for every domain and subdomain
I use Plesk and I have three domains and subdomains with different ngnix configs. At the moment I change the ngnix config in the /etc/ngnix/plesk.conf.d/vhost/manual after every update, because my changes are being overwritten by the httpdmng.Now to my question; Can I create a separate template in /usr/local/psa/admin...
Plesk really shouldn't have its core edited. When you need domain level config changes there's a file you need to edit outside that file. Under Apache that file was calledvhost.confunder the directory for your domain. It would then append that to the base config. It looks like nginx uses a similar process.Based onthis ...
Nginx set up nodejs in port 80
i want bind nodejs to a url, like this:http://myproject.com/nodejs/Currently, i have node in port 8080.And i have nginx configuration :upstream app { server 127.0.0.1:8080; } server { listen 80; ## listen for ipv4; this line is default and implied root /home/myproject/www; index index.html index....
It was replied earlier in another thread:https://stackoverflow.com/a/12904282/2324004Unfortunately, Socket.io wiki lacks of some of information but the clue is to set up resource:Clientvar socket = io.connect('http://localhost:8081', {resource: 'test'});Servervar io = require('socket.io').listen(8081, {resource: '/test...
AWS and Node.js, do I need nginx or apache?
I did post this on serverfault, but not getting any views or responses.I've read a bunch of posts on here about whether or not you need a webserver when using Node.js, and the answer always seems to be yes to serve up static files.My question is this though. If the site I'm working on is mostly dynamic, couldn't I just...
I can't speak explicitly to node.js architecture decisions, but I can address your CloudFront and ELB questions.CloudFront is a great CDN for static assets, but there are a few gotchas. As the saying goes,"There are only two hard problems in Computer Science: cache invalidation and naming things."If you want to replace...
Rails JavaScript views not working in production
I'm having an unexplainable issue with my Rails app. I'm using a lot of JavaScript in all parts of the app. In development everything is working just fine, but in production it seems that the code in my javascriptviewsis not executed.This is particularly odd because all other JavaScript on the page works great. Custom ...
You should movecoffee-railsgem from the:assetsgroup to the main group.
Nginx conf for two gunicorn applications (django and tilestache)
I'm trying to host a site that consists of a django app and map tiles served by tilestache. I can get them running and serving content separately by using eithergunicorn_django -b 0.0.0.0:8000for the django app, orgunicorn "TileStache:WSGITileServer('tilestache.cfg')"for tilestache. I've tried daemonizing the django ap...
As far as I see - you have mappedlocation /to go tolocalhost:8000. When you have 2 different upstreams, you'll need two different location mappings, one for each upstream. So assuming that the django app is the primary site on your domain, you'll have the default location as it is now:location / { proxy_pass_heade...
How can I detect mobile devices (and/or mobile cookie) without scripting (PHP) or server configuration (Nginx)?
We are launching a mobile version of our website very soon. Our full website and mobile website are different only in theme, i.e. URLs are the same, only difference is on the front-end.We need to be able to do the following when a user visits our site:1.Check a cookie (mobile == true OR false) to determine if full vs. ...
You could use javascript.Try this:http://detectmobilebrowsers.com/
Nginx vs Apache or using Apache with nginx [closed]
Closed. This question isopinion-based. It is not currently accepting answers.Want to improve this question?Update the question so it can be answered with facts and citations byediting this post.Closed10 years ago.Improve this questionI have been running a website which servers javascript widgets for about 2 years. Now ...
You could still use the rewrite rules from Apache, with slight modifications (I took this fromNginx Primer):Apache:RewriteCond %{HTTP_HOST} ^example.org$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]Nginx:if ($host != 'example.org' ) { rewrite ^/(.*)$ http://www.example.org/$1 permanent;...
django on nginx & apache : where to handle 404 & 500 error?
I know there is 404 error handling in django. But is it better to just put that config in nginx ?This ST thread has the solution for putting it. -http://stackoverflow.com/questions/1024199/nginx-customizing-404-pageIs that how everyone handles it when using nginx ?I have created my own 404.html & 500.html in the sites...
You haven't mentioned any reasons why you would want to put these pages in the Nginx server. I would recommend keeping it with the rest of your site, that is, on the Django server. Moving part of your site to the Nginx server is a good idea to solve scalability problem, but complicates your deploy. I certainly hope ...
Which has a better code base to learn from: nginx or lighttpd?
Primary goal is to learn from a popular web server codebase (implemented in C) with priority given to structure/design instead of neat tricks throughout the code.I didn't include Apache since its code base is an order of magnitude larger than the two mentioned.
I didn't include Apache since its code base is an order of magnitude larger than the two mentioned.Actually Apache code is quite readable. It has large code base because it does lots of things. But it is well structured and quite easy to understand. You can also check APR library (Apache Portable Runtime) which has ple...
Django: Unicode Filenames with ASCII headers?
I have a list of strangely encoded files:02 - Charlie, Woody and You/Study #22.mp3which I suppose isn't so bad but there are a few particular characters which Django OR nginx seem to be snagging on.>>> test = u'02 - Charlie, Woody and You/Study #22.mp3' >>> test u'02 - Charlie, Woody and You\uff0fStudy #22.mp3'I am usi...
Although/is an unusual and undesirable character, your script will break foranynon-ASCII character.response['X-Accel-Redirect'] = urlurlis Unicode (and it isn't a URL, it's a filepath). Response headers are bytes. You'll need to encode it.response['X-Accel-Redirect'] = url.encode('utf-8')that's assuming you're running ...
How to not need a .dotted file path in nginx configuration
I'm trying to serve my AppLink for google association services. The following works:location /.well-known/assetlinks.json { root /var/www/static/google-association-service/; types { } default_type "content-type: application/json"; }Provided I have the correct file placed at/var/www/static/google-association-ser...
aliasbasically gives you the possibility to serve a file with another name (e.g. serve a file namedfoo.jsonat location/.well-known/assetlinks.json). Even if this is not required in your case I would favor this config, as it is easily understandable:location = /.well-known/assetlinks.json { alias /var/www/static/goo...
NGINX - Can't set content-type header
I'm usingnginx/1.10-3on Debian.I have a file named logo.img which infact is an svg.I've modified/etc/nginx/mime.typesto include the.imgas an extension for the svg file type:image/svg+xml svg svgz img;But the headers of the file served is stillapplication/octet-streamFor some bizarre reason, i've been asked to serve t...
The/etc/nginx/mime.typesfile already contains a mapping for URIs ending with.img, which is set toapplication/octet-stream.When you edit the file, did must also remove this existing mapping.Alternatively, you can override the content-type for a single URI.For example:root /path/to/root; ... location = /images/logo.img {...
Redirect Elastic Beanstalk HTTP requests to HTTPS with nginx
I want a redirect from HTTP request to HTTPS on Elastic Beanstalk with nginx as proxy system.I've found a lot of advices on Google but no one helped, it doesn't redirect.That is my currenttest.configfile in.ebexentionsdirectory:files: "/etc/nginx/conf.d/proxy.conf" : mode: "000644" owner: root group: root ...
Thisis the only solution that worked.It's necessary to overwrite the default nginx file after AWS created it. So there has to be two more files:Write the nginx file.Create a script that overwrites the default nginx file.Run the script after AWS created the default file.
Bash: Nginx Version check cut
I'm trying to check if the installed nginx version is equal with the version defined in a config file.My code:#check version command="nginx -v" nginxv=$( ${command} 2>&1 ) nginxvcutted="echo ${nginxv:21}" nginxonpc=$( ${nginxvcutted} 2>&1 ) if [ $nginxonpc != ${NGINX_VERSION} ]; then echo "${error} The installed Ng...
You can use regular expression instead of cut. For example to extract version number fromnginx-1.15.0use:echo 'nginx-1.15.0' | grep -o '[0-9.]*$'Output:1.15.0
nginx: rewrite a LOT (2000+) of urls with parameters
I have to migrate a lot of URLs with params, which look like that:/somepath/somearticle.html?p1=v1&p2=v2 --> /some-other-path-aand also the same URL without params:/somepath/somearticle.html --> /some-other-path-bThe tricky part is that the two destination URLs are totally different pages in the new system, whereas in ...
You cannot match the query string (anything from the?onwards) inlocationandrewriteexpressions, as it is not part of the normalized URI. Seethis documentfor details.The entire URI is available in the$request_uriparameter. Using$request_urimay be problematic if the parameters are not sent in a consistent order.To process...
nginx - rewrite location to root of server
I have thisnginx.confnginx configuration:http { ... upstream app_servers { server admin; } upstream status_servers { server status:5000; } # Configuration for the server server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; ...
Solved it usingrewrite ^/api(/.*)$ $1 break;but I can't just using/api- it must be/api/(with trailing/)For me it's fine, interesting though if anyone knows how to have support for/apitoo.
Nginx proxy for OAuth2 validation
I have an own OAuth2 provider where you can ask for a token and validate it. I want to protect my REST API (resource server) with OAuth2, so, in every single request, the access token must be validated, against OAuth2 server.I have been doing this validation in the REST API code itself, by intercepting every request an...
Yes, you can use theauth-request modulein nginx.
nginx authorization based on client certificates
I have SSL enabled in nginx with the client certificate enabled in my browser. With this I'm able to hit my site via HTTPS through port 443.What I'm looking for now is to use this information about the client to allow access to different parts of the API (URLs) but deny access to other parts. I can do this using IP a...
For access check you can useifdirective and ssl module variables:$ssl_client_s_dn,$ssl_client_serial. Examplelocation /not/for/jhon/ { if ($ssl_client_s_dn ~ Jhon) { return 403; } }Good way to maintain list of allowed certificated themapdirective. Examplemap $ssl_client_s_dn $ssl_access { default 0; 01 1; 0...
How to use custom location or path instead root for several apps using nginx?
ProblemI have a web which works fine on a root domain likemydomain.comwithout any modification. But if I want to serve it asmydomain.com/app1I I need to modify the source code in the backend and statics links (css, images, etc) in the htmlnodejs :fromapp.get('/')toapp.get('/app1')htmlfromsrc="main.css"tosrc="app1/main....
Should you always modify the application when you want to assign a domain/path?No, you shouldn't have to modify the application at all.When you useproxy_passin this manner, you need to rewrite the URL with regex. Try something like this:location ~ ^/app1/(.*)$ { proxy_pass http://localhost:8080/$1$is_args$args; ...
Nginx, uWSGI, Flask app doesn't show changes until the server is restarted
Every time I update my Python file, I have to reboot the server to see changes. I have tried restarting Nginx and uWSGI with no luck. Flask is running in debug mode. How can I see changes without rebooting the entire server?app.pyfrom flask import Flask import time import cv2 app = Flask(__name__) @app.route("/") def...
So, one way I got around this was to do this in my uwsgi.ini filetouch-reload = /home/vagrant/PythonVision/app.pyThen I touch the file app.py and BANG sorted
Why HTTP/2 on a specific site works in FF, but doesn't work in Chrome, IE and Edge on the same Windows 10 computer?
I have a site, that runs on a Nginx 1.10.0 on Ubuntu 16.04 server (OpenSSL 1.0.2h). I want to serve this site over HTTP/2, so I configured Nginx accordingly:listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_serverAnd it works fine in FF 47 and Chrome 51 on my office Ubuntu 15.10 desktop and in the ...
Are you using antivirus software (e.g. Avast) and is it inspecting your HTTPS traffic?It does this by acting like a MITM so you connect it it and it connects to the real website. And if they only support http/1 (which as far as I know they only do) then that would explain this. Though oddly not for for Medium unless yo...
Docker Beta on Mac : Cannot use ip to access nginx container
I installed the docker-beata (https://beta.docker.com/) for osx. Next, I created a folder with this filedocker-compose.yml:web: image: nginx:latest ports: - "8080:80"After, I used this command :docker-compose up. Container start with success.But the problem is to access in my container. I don't know what ip use...
As @Javier-Segura mentioned, on with native Docker on Linux you should be able to hit the container via it's IP and port, so in your casehttp://172.17.0.2:80- the 8080 port would be on the host IP.With Docker for Mac Beta it does not appear to work the same way for the container. It changes a bit with every release but...
cant get ab test to work with gzip
this is my nginx gzip config:gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 4; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;I approve that it works by all the gzip testing websites that confirim my site ...
so I needed to add to the nginx configgzip_http_version 1.0;the default which is 1.1 was not good I guess for apachebench
extending mime types in a Chef deployed Nginx server
I'm looking to extend the mime types in my Nginx configuration.I've learned that I could, in principle, either edit the mime.types file, or after including mime.types in thehttpblock of the config you could followinclude mime.typeswith atypes = {...}to append more types a lathis answer.Since I'm setting up Nginx with C...
Although not explicitly stated in the documentation, thenginxtypes directive appears to behave similarly to other directives with regard to inheritance.The directive is inherited from the previous level if and only if there are notypedirectives defined on the current level.Thetypesdirective may appear in thehttp,server...
phpmyadmin on NGINX with Centos7 shows blank white page?
I am using Nginx with Centos 7 which is working fine.After that I installed phpMyAdmin which was successfully installed as well, however when I access it on the browser it shows white blank page with no HTML source code.What am I doing wrong?
I've found the solution.The /var/lib/php/session/ folder was not writeable by nginx/php-fpm, I've just edited the permissions to 777 and now it works.
How to add ngx_http_map_module into nginx
I'm having problems adding the modulengx_http_map_moduleinto my nginx ./conf I tried the--with-ngx_http_map_moduleparam but it doesn`t work. I'm kinda new to this so I could be doing something wrong. After I run that configuration I get this error :./configure: error: invalid option "--with-http_map_module"What am I do...
Reading the fileauto/optionsgives me the impression that this module is enabled by default.See the definitionhere:HTTP_MAP=YESand the definition of a./configureoptionhere:--without-http_map_module
Is it possible to run (and check) Nginx rewrite rules without running the whole web server?
I want to get as close as I can to "unit testing" Nginx rewrite rules. How close can one get to doing this? Is there a way to run the request rewriting module without running the entire web server? Can I embed the Nginx server in a process running Ruby or Python or, if I have to, Java? What tricks can you think of?
Put your rewrite rules in an include file.Create Nginx configuration just for testing that pulls in the rewrite include file.Using the-cand possibly the-gflags, Runnginxas a user. Since you can run it on an alternate port, this won't conflict with a web server running on port 80.Have your automated testing run tests ag...
Redirect location includes ":80" when X-Forwarded-Proto is https
Nginx terminates SSL for our app, communication between Nginx and app servers happens on port 8080, our app had nograils.serverURLset in config.We had a regular redirect:redirect uri: '/login'But when accessed via HTTPS the redirect returned:Location: https://domain.com:80/loginAs a result browsers attempt to open SSL ...
Removing theX-Forwarded-Protoheader fromnginx.confor addingX-Forwarded-Port(recommended) resolved the issue.