FAQ Database Discussion Community


nginx static images fallback

nginx,static-files,fallback
i use nginx 1.6.2 to serve static images from a folder. I need to serve the requested file if exists or fallback to a default image. i had this location block location /test/img/ { rewrite ^/test/img/(.*) /$1 break; root /path/to/folder/images; try_files $uri /default.jpg; } The "/path/to/folder/images" folder contains 2 files:...

Phalcon 2.x skeleton app with modules doesn't produce 404 Not Found if path is not found

php,nginx,phalcon,phalcon-routing
I've generated a skeleton app using dev tools that has a single module. The problem I have is that whatever URL I type in the browser - it always returns the content in apps/frontend/views/index.volt (frontend is the module name). Here is my services.php <?php /** * Services are globally registered...

Changes in Javascript not being reflected while debugging Web page

javascript,php,nginx
I am working on a web page development using netbeans IDE and use Firefox for debugging/testing. Whenever i do changes to Javascript, these changes are not getting reflected on the web page,the source code reveals the obsolete code. Everytime i make changes, i ensure to restart my nginx server before...

PHP: Tor check not working

php,nginx,ip,tor
I've installed a Tor relay and Nginx and created my .onion on my Linux server. In torrc HiddenServicePort 80 127.0.0.1:8747 In nginx's default: listen 8747 I've modified TorDNSExitList's PHP Pear Net_DNS to use Net_DNS2. When I echo out the $ip, $myip, $myport I get: ip = 127.0.0.1 my ip =...

nginx + fcgiwrapper sporadic Prblem: Delivers application/octet-stream instead of text/plain

http,nginx,content-type,fastcgi,plaintext
I am new to this forum. This is my first question. I have a nginx-server + fcgiwrapper set up to run Programs on user request (no PHP). For testing I have a simple bash script, which displays the environment variables and sets two cookies, a second bash-script prints "Hello World"...

Augeas in Puppet for mysql config failing

mysql,nginx,puppet,augeas
I'm currently developing some basic Puppet manifests and modules to install my application dependencies after my server has been deployed. It's a suite of basic stuff: - OS -> Ubuntu 14.04 LTS Nginx PHP5-FPM MySQL Simple, right? Everything is going pretty well for the most part; until I stumbled upon...

Nginx 504 timeout initial wordpress installation

php,wordpress,nginx
I am trying to access a WordPress installation with an IP Address. I get a 504 timeout error. However, I added an info.php page and I get the page served to me by requesting it at xx.xx.xx.xx/info.php. The logs give me this error: upstream timed out (110: Connection timed out)...

Nginx disable or decode url encoding when writing to access log

nginx,lua,openresty
I have an open resty nginx with lua code that enhance the data and then I write this data to the access log for data analysis. The data that the lua code produce includes double quotes but nginx write it to the access log as \x22. Can I disable this...

Errors downloading Powerpoint and PDF files after nginx update

pdf,nginx,download,gzip,powerpoint
I am hosting my site on an nginx server at DigitalOcean & ran some updates. Before the updates, I was able to upload PDF and Powerpoint files to the server and download them without problems. Now, whenever I try to download a file I recieve an error "Powerpoint found a...

502 Bad Gateway - Nginx - Unicorn suddenly stopped working, Nginx logs empty

ruby-on-rails,ruby,nginx,unicorn
BIG EDIT WITH THE ANSWER If your Nginx application throws you a "502 Bad Gateway", check inside your Nginx conf files /etc/nginx/conf.d/*, probably you might have the same domain declared twice in different .conf files. Nginx error logs WON'T show you anything. ===== I have a few Rails Applications running...

Ensure nginx master process stays running

nginx,docker,supervisord
I am currently trying to setup a docker container using ubuntu:14.04 as my base image, with nginx and gunicorn/django/celery running inside. I am using supervisor to start all of the processes, and have tested to make sure gunicorn is relaunched when it goes down. However, I can't figure out how...

Can't delete nignx's temporary files without sudo

nginx,archlinux
I've installed nginx the regular way on Arch Linux. Anytime my website (ie nginx) creates temporary files, it's created by the http:http user and they have 755 permission. I need to clear the cache time to time and I am logged as a regular user. That means anytime I need...

Installing Passenger & Nginx using Vagrant shell script

shell,nginx,vagrant,passenger
This is my first post to SO so I hope I'm asking this correctly. I wrote a shell script to automate the installation of Passenger & Nginx (along with some other components) without any user input on a Vagrant VM running Ubuntu 14.04. It works fine using the following: echo...

Trouble with Nginx Rewrite Rules

php,.htaccess,nginx
I'm fairly new to Nginx, and I'm working on converting an .htaccess file into something nginx can make sense of. Everything's working well (mostly) - I can pull up the homepage just fine. The problem is when I get to a post page. think similar to wordpress, URLs like: http://www.example.com/12/post-title-in-slug-form...

nginx not serving django static files

python,django,nginx
I'm running my django project on amazon AMI machine and have problem with nginx serving static files. Project static folder path is /home/user/projectname/app/static and nginx.conf is server { listen 80; location /static { alias /home/user/projectname/app/static; } location / { proxy_pass http://localhost:8000; } I tried to make collectstatic and change static...

Deployment of Python API

django,api,nginx,deployment,uwsgi
I'm trying to understand the simplest way to deploy a Django application in production. Many recommend nginx or Apache along with uwsgi or gunicorn. I think that is more than my situation requires, and I would like know if my thinking is correct. This application is nothing more than an...

Why I must install gems manually after deploy using Capistrano

ruby-on-rails,ruby,nginx,passenger
Ubuntu server, production mode. Install RVM with ruby (2.0) and Bundler. Capfile: # Load DSL and Setup Up Stages require 'capistrano/setup' # Includes default deployment tasks require 'capistrano/deploy' # Includes tasks from other gems included in your Gemfile # # For documentation on these, see for example: # # https://github.com/capistrano/rvm...

Django Reduce the template Rendering Time

javascript,html,django,nginx
I am using Django 1.7 and nginx. My sample view file is, def testing(request): return render_to_response('pages/testing.html', ) def testing1(request): return render_to_response('pages/comingsoon.html',) def testing2(request): x= User.objects.all() return render_to_response('pages/index1.html',{'users': x,}) def testing3(request): context = User.objects.all() return render_to_response('pages/testing.html',) pages/testing.html - contains only text.(pure text) pages/testing1.html - contains css and js pages/testing2.html - <body>...

Elasticsearch head plugin not working through nginx reverse proxy

nginx,elasticsearch,reverse-proxy,elasticsearch-plugin
I have elasticsearch with the head plugin installed running on a different server. I also set up an nginx reverse proxy for my ES instance. The configuration looks like below: http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name es.mydomain.net; location / { proxy_set_header...

How can I make a special URL like "http://appname/

networking,nginx,proxy,reverse-proxy
I know some applications run on companies' internal networks with URLS like "https:/statsd/", so I was wondering how to go about doing this. I was thinking maybe I would use a reverse proxy like Nginx to proxy all urls that match a particular regex to the correct server, but I...

How to block Referrer Spam

nginx,spam-prevention
hello i am using Nginx and one of my site is suffering from referrer spam, I followed Nginx wiki i found this but after using this code, it is blocking my site .Is there any solution i have also tried using this code but it did't worked if ($http_referer ~...

Getting nginx 404 error on uploaded files

nginx,plesk
I am using PHP (5.3) to upload jpeg files, create folders for those files and store them. I have a development version and a live version both running on the same server (CentOS 7, Apache, Plesk 12). On the live version, I am experiencing no problems, but on the dev...

How to configure Rails 3 app hosted on sub-url with Puma and nginx?

ruby-on-rails-3,nginx,puma
With Phusion Passenger, there are specific directives to use in the nginx virtual host configuration that allow Rails apps to be hosted on sub-urls. This is described in the Phusion Passenger documentation. With Puma, I am using sockets. My nginx config includes: upstream subapp { server unix:<path_to_subapp_folder>/shared/sockets/puma.sock fail_timeout=0; } server...

Nginx: setting the error page to a static file

nginx,configuration,system
I have the following nginx configuration: server { listen 80; server_name default; location / { proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080/; } } When the internal service at http://127.0.0.1:8080/ is not responding nginx return a 502 Bad Gatway error. My question: how can I configure nginx to returning a static html...

Convert Apache VirtualHost to nginx Server Block for Dynamic Subdomains

apache,dynamic,nginx,vhosts
I have a web app running on Apache where the virtual hosts file is configured to route requests to subdomains to specific folders. Rather than having to modify the host file every time a subdomain is created, this allows me to dynamically route URLs to the relevant folder (with a...

I need to do a redirect on a proxied path in Nginx

nginx,proxy,url-redirection
I'm working with a poorly architected app and I have a need to proxy / and redirect it to a sub-directory (unless someone can comeup with a better solution). Here's the layout of the paths the app uses: var securePaths = [ "/someaction", "/anotheraction", "/athirdaction", "/client/interfaceishere/index.html" //path to client interface...

Wordpress Multisite on Nginx giving 404 for files

php,wordpress,nginx
Hello I have set up a WordPress multisite on LEMP stack using VPSSIM I have migrated this setup from another server which was running on Apache. Like if you see this website ( http://goo.gl/U5xNSV ) that is part of WordPress multisite, you will see many 404 erros in the page....

Php has its own /tmp in /tmp/systemd-private-nABCDE/tmp when accessed through nginx

php,nginx,centos7,tmp
I found strange behaviour concerning php and /tmp folder. Php uses another folder when it works with /tmp. Php 5.6.7, nginx, php-fpm. I execute the same script in two ways: via browser and via shell. But when it is launched via browser, file is not in real /tmp folder: <?php...

SQLAlchemy extension isn't registered when running app with Gunicorn

nginx,flask,flask-sqlalchemy,gunicorn
I have an application that works in development, but when I try to run it with Gunicorn it gives an error that the "sqlalchemy extension was not registered". From what I've read it seems that I need to call app.app_context() somewhere, but I'm not sure where. How do I fix...

Django: Internal Server Error

python,django,nginx,digital-ocean
This is my first time deploying Django website on DigitalOcean and it causes me a lot of problems. I am using one click install, deployed my website from git and changed gunicorn and nginx files, but still it gives me Internal Server Error. Here is the Apache log: 2015-05-18 15:24:08...

Tornado behind Nginx, should I use TCP nodelay config in python or nginx.conf?

nginx,tcp,websocket,tornado
I have a Tornado server running behind Nginx reverse proxy. The proxy is configured with tcp_nodelay: on. I see there's also an option to call WebSocketHandler.set_nodelay(True) on a WebSocket instance once it's connected. Do these two create the same effect? Are there pro's con's for using one over the other?...

Nginx express static files not found

file,express,nginx,static
I am trying to serve static contents with nginx instead of express. Nginx server block static file part is location / { root /var/www/analytics/web/static; try_files $uri $uri/ @analytics_web; expires off; add_header Cache-Control no-cache; } The static resources are in /var/www/analytics/web/static and they get served if i include app.use('/static', express.static(app.get('config').paths.static)); in...

Rails controller action hanging

mysql,ruby-on-rails,ruby,ruby-on-rails-4,nginx
I am a newbie in ruby/rails and have been breaking my head with a problem for the past 2 days and am hoping that someone in this forum can help me out with it. I am working on rails 4 and running an application in production using Passenger + Nginx...

Only allow certain countries traffic access specific page

nginx,server,geoip,system-administration
I am using --with-http_geoip_module for identify traffic. There are some pages that I only want certain country to access. Here is configuration: For http http{ geoip_country /usr/share/GeoIP/GeoIP.dat; # the country IP database map $geoip_country_code $allowed_country { default 0; US 1; UK 1; HK 1; } } The location directive: location...

Elasticsearch basic auth with nginx

nginx,elasticsearch
I have the following set-up: /etc/nginx/sites-available/elasticsearch server { listen 80; server_name xxx.xxx.xxx.xxx; auth_basic "Elasticsearch Authentication"; auth_basic_user_file /etc/elasticsearch/es.pwd; location / { rewrite ^/(.*) /$1 break; proxy_ignore_client_abort on; proxy_pass http://localhost:9200; proxy_redirect http://localhost:9200 http://xxx.xxx.xxx.xxx/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } } whenever I do curl -i -u...

passenger issue with cloud66 deploy

ruby-on-rails,nginx,passenger,cloud66
when i deployed using cloud66 I got this: First time this happened: We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly. The Phusion Passenger application server encountered an error while starting your web application. Because you are running this...

Is Nginx + Node.js + Socket.io + SSL possible?

node.js,ssl,nginx,socket.io
I'm trying to run a socket.io chat app with nginx as proxy. It works fine when I connect to the server via http+port, but it doesn't work with https. I see user connected/disconnected events pass through, but no emit reach client or server. Here's my server .conf (nginx/1.4.6 Ubuntu) upstream...

Convert .htaccess to nginx, seeking working solution

apache,.htaccess,mod-rewrite,nginx
Hello i am aware that there are some .htaccess2nginx converter outside, and well, still need some help, since it's not working at all. To my problem: Setting up an Imageboard(MyImouto) on Nginx, Imageboard uses .htaccess to redirect from /srv/domain/public/ to /srv/domain/app/... Here is the .htaccess: RewriteEngine On # Images redirection....

django apps on nginx running separatelly from apache

django,apache,nginx
I am installing production server for my django apps and I can not make it work. My configuration files can be found here. Basically I have apache2 installed and running on port 80 for my php applications. I want to run my django apps on nginx with uwsgi, apart from...

How to change default Nginx setting on Homestead Laravel Virtualbox VM

laravel,nginx,vagrant,virtualbox,homestead
I merely followed the default Laravel Homestead setup here using VirtualBox. Working great. But I need an additional Nginx rewrite setting in my apps vhost file on the VM, something like; location / { if ($request_method !~ "(POST)"){ rewrite .... } try_files $uri $uri/ /index.php?$query_string; } I can add that...

nginx always serves welcome page

nginx
I'm trying to make nginx proxy requests to a Django server, but it keeps showing the nginx welcome page. Here's /etc/nginx/nginx.conf: worker_processes 4; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile off; tcp_nopush on; keepalive_timeout 65; gzip on; gzip_disable "msie6"; include /etc/nginx/sites-enabled/*; server { listen 8000...

Unicorn+Nginx concurrency and data duplication

ruby-on-rails,ruby-on-rails-3,nginx,concurrency,unicorn
I have 4 Nginx workers and 4 unicorn workers. We hit a concurrency issue in some of our models that validate unique names. We are getting duplicated names when we send multiple requests at the same time on the same resource. For instance if we send around 10 requests to...

Why does my rails automatically decode URL? How can I stop it?

ruby-on-rails,ruby,nginx
I was trying to fetch a URL like this: http://myweb/api/1/1/NJUimQw0bsJgv%2FqjfpMzCl5CeeL%2BnCQr61UVLBcJCNA%3D%0A However, the log file shows: ActionController::RoutingError (No route matches [GET] "/api/1/1/NJUimQw0bsJgv/qjfpMzCl5CeeL+nCQr61UVLBcJCNA=%0A"): It seems that rails automatically decodes URI. How can I disable it? In my route.rb: scope '/api' do get '/:aid/:uid/:token' => 'my_apis#show' end My website is rails 4.2.1 and...

Understanding server architecture: Delivering content from AWS S3 using Nginx reverse-proxy or Apache server

apache,amazon-web-services,nginx,amazon-s3
The purpose of this question is to understand the strategy while designing server side architecture. Use case: I want to build a http server for an app which allow users to upload and download multimedia content (images, videos etc.) Large number of concurrent users (say, around 50k) are expected to...

How to track bytes sent in Nginx

nginx
I'm using NGinx as a large file content delivery server, I need to track how many bytes are sent to the client when they download a file. Then with some ID deduct the bandwidth from their account. Here is my Nginx config, but it doesnt seem to work. On my...

Nginx password on FreeNAS (FreeBSD) htpasswd

nginx,freebsd,.htpasswd
I have nginx running on FreeNAS in a jail in front of various plugins like transmission, couchpotato, etc. As far as I know FreeNAS is based on FreeBSD. I'd like to expose this server to the outside world, but can't work out how to set a password on nginx, as...

Bytes form nginx logs is mapped as string not number in elasticsearch

nginx,elasticsearch,logstash,data-type-conversion
recently I deployed ELK and started forwarding logs from nginx through logstash frowarder. Problem is, that in elasticsearch (1.4.2) / kibana (4) is "bytes" value of request mapped as string. I uses standard congfiguration found everywhere. Into logstash patterns added new pattern for nginx logs: NGUSERNAME [a-zA-Z\.\@\-\+_%]+ NGUSER %{NGUSERNAME} NGINXACCESS...

Spring Boot configure a Domain/Host to access in a www.website.com fashion

tomcat,nginx
I have a spring boot application. Usually I run my Spring applications on PaaS instances, and configuring a domain name from there is easy enough, however I am running this on a Virtual Private Server, and I cannot, for the life of me, figure out how to run my spring...

Nginx ldap auth login by different attributes

nginx
I need to configure nginx to sign in by two kinds dn : cn=appname,ou=Applications,o=example.com uid=username,ou=People,o=example.com Here is piece of code for ldap server: ldap_server ldapserver { url ldaps://ldap.example.com/o=example.com?uid,cn?sub?(..filter for search...) } However, only username can be signed in, appname can't. But if I switch the position of uid and cn...

How can I avoid uwsgi_modifier1 30 and keep WSGI my application location-independent?

nginx,uwsgi,cherrypy
I have a WSGI application using CherryPy hosted using uWSGI behind a ngnix server. I would like for the application itself to be "portable". That is, the application should not know or care what URL it is mapped to, and should even work if mapped to multiple different URLs. I...

How can I pull opsworks variables into a .env file with chef?

php,amazon-web-services,nginx,laravel-5,aws-opsworks
I am very new to chef and am on the last piece of the puzzle. I am trying to create a .env file in my project root using variables set in AWS Opsworks. I can't for the life of me figure it out. Does anyone have any suggestions or a...

Wrap resources inside custom class and invoke class?

nginx,puppet
I am using Puppet 3.0. I tried to use the existing NGINX module but encountered one issue which no answer seems to exist. I have moved to implementing NGINX module myself which handles my exact requirements. Each package/service/file resource works as expected and now I am moving the code out...

Using Vagrant with SaltStack, how do I start nginx after providing custom configuration

nginx,vagrant,salt-stack
I have a Vagrant boxset up to provision with salt. When I do a fresh vagrant up (after a vagrant destroy), nginx defaults to port 80 and the default welcome page, despite not being configured to. I can fix it by manually running sudo nginx -s reload inside the guest,...

How to deploy a python project with Nginx?

python,nginx,socket.io,server
I have wrote a client.py and a server.py, they talk to each other with socket(not websocket) TCP connection.This is a C/S application. Now i want to use nginx to deploy the server, but i dont know how to do. I have look through some material about nginx, which is only...

MAMP or Mac nginx MySQL Lua

mysql,nginx,lua,osx-server
I've recently purchased a Mac Mini with the only purpose of being a server. I'm a C programmer, learning Lua and Obj-C at the moment. I'm trying to set up a website, a kind of CV/Personal Promotion site. I've been looking at MAMP for a while however, I would like...

Multi-domains I/O n CPU restrictions via nginx vps

nginx,vps
on shared hosting you have limiation on how many Disk I/O your site will use , how much ram you will use etc. On VPS ubuntu with nginx with many sites , is it possible to do that? for example i want one site to get 80% of vps' recourses...

nginx FastCGI-strip off the location prefix?

nginx,fastcgi,web.py
I'm writing a web application in Python using web.py, spawn_fcgi and nginx. Let's say that I have this configuration block in nginx: location / { include fastcgi.conf; fastcgi_pass 127.0.0.1:9001; } If I then access, say, http://example.com/api/test, then the FastCGI application receives /api/test as its request location. The web.py framework will...

DNS custom domain to subfolder

nginx,dns
I have a SaaS app where every user has a personal subdomain: username.domain.com. Every user has a personal blog at username.domain.com/blog. Now I want to accept custom domains, e.g. www.mycustomblog.com would be an alias for username.domain.com/blog. If someone browses to www.mycustomblog.com/123, the page username.domain.com/blog/123 should be served. However, I do...

Nginx page displaying instead of home page (Digital Ocean - LEMP)

ubuntu,nginx,digital-ocean
I recently bought a DigitalOcean account, and am attempting to set up my web site. However, whenever I enter the IP address of my site, I get this page: Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required....

Serving Static Files Through Flash and Nginx?

python,nginx,flask
I have some static files I've been serving through Flask. On a given request, I run some processing and authentication, and then serve the file. I've been doing that using Flask's send_from_directory, but it looks like that caches the file for a bit, which is no good for me. I...

Ruby on Rails + Michael Hartl tutorial + VPS = issues with AWS

ruby-on-rails,ruby-on-rails-4,amazon-web-services,nginx,fog
I have finished Michael Hartl tutorial and I'm trying to deploy it with https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04. Unfortunately I'm stuck with RAILS_ENV=production rake db:migrate because it's generating following error: ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key /home/me/simpleapp/config/initializers/carrier_wave.rb:3:in `block in <top (required)>' /home/me/simpleapp/config/initializers/carrier_wave.rb:2:in `<top...

How to create rewrite rule to Rename PDF file on the fly while Downloading using nginx?

mod-rewrite,nginx,rewrite
i am working on site where i am allowing users to download PDF files. Each PDF file is stored on server using random hash names, eg. file 768E1F881783BD61583D64422797632A35B6804C.pdf is stored in /usr/share/nginx/html/contents/7/6/8/E/1/768E1F881783BD61583D64422797632A35B6804C.pdf now i can try to give users the direct location of file , but the file name after...

NGINX Serve all static files and forward others to proxy without / giving 403?

node.js,nginx,proxy
I'm trying to configure an nginx server to act as a proxy to a node application. What I would like is to have any static files served by nginx and all other paths forwarded on to the Node.js application (inluding the / path). I've seen the following question/answers: How to...

nginx- duplicate default server error

nginx
In my error log i get [emerg] 10619#0: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/mysite.com:4 on Line 4 I have: server_name mysite.com www.mysite.com; Any suggestions?...

Have created a docker that installs nginx, python, uwsgi and django. How do I test it within a VM?

django,nginx,docker,uwsgi
I have created the following project using docker. Here is the Dockerfile ############################################################ # Purpose : Dockerize Django App to be used in AWS EC2 # Django : 1.8.1 # OS : Ubuntu 14.04 # WebServer : nginx # Database : Postgres inside RDS # Python : 2.7 # VERSION...

Meteor app deplayed with mup, behind nginx not displaying

javascript,nginx,meteor
I'm trying to get an app deployed to my own server with mup to work behind nginx so that I can direct port 80 with a route to be the app (other things running on there on the default page). The app is running fine on http://hostname:3080 but when I...

What does `expires -1` mean in NGINX `location` directive?

caching,nginx,cache-control
Given the sample location example below, what does -1 mean for expires? Does that mean "never expires" or "never caches"? # cache.appcache, your document html and data location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; access_log logs/static.log; } https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/location/expires.conf...

How to pass nginx proxy url for socket

node.js,sockets,nginx,proxy,socket.io
I am using socket in my application,i want to pass socket connection url from nginx as proxy url.I am doing it like that My socket code var socket = io.connect('/explorer/socket',{ 'reconnect': true, 'reconnection delay': 500 }); My nginx conf location /explorer/socket { proxy_pass http://xxx.xxx.xx.xxx:3000; } but it is not working,it...

How do I turn sendfile off in a docker instance

linux,nginx,configuration,docker,sendfile
I have a nginx docker instance running. In the docker instance there is a file called /etc/nginx/nginx.conf It has the following settings http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" access_log /var/log/nginx/access.log main; sendfile on; .... } I run the docker instance by running with...

Nginx HTTPS issue to redirect from www to non-www

ruby-on-rails,ssl,nginx
I need to configure nginx for one of my rails application to route some pages through SSL but facing problem with configuration. I've a SSL certificate where common name is example.com and my site is routing to example.com from www.example.com Here is my nginx.conf: upstream unicorn { server unix:/tmp/unicorn.sock fail_timeout=0;...

How can I stop nginx from responding to non-local requests?

nginx
Here's what my nginx file looks like. However when I browse to my server using the ip, I still the the "Welcome to nginx!" page server { listen 127.0.0.1:9070; root /var/www/[redacted]/public/; index index.php index.html index.htm; server_name [redacted]; location / { try_files $uri $uri/ /index.php$is_args$args; allow 127.0.0.1; deny all; } #...

nginx uwsgi websockets 502 Bad Gateway upstream prematurely closed connection while reading response header from upstream

django,nginx,websocket,redis,uwsgi
I've been banging my head on this issue for days now and have finally reached a brick wall. I've been trying to get my stack to run: http://django-websocket-redis.readthedocs.org/en/latest/running.html#django-with-websockets-for-redis-behind-nginx-using-uwsgi I've been looking at some other SO articles like this one: nginx - uWSGI HTTP + websocket config They seem to have...

How to rewrite the url in tornado

nginx,tornado
I'm learning tornado and nginx these days,and I'm confused about the url rewrite. for example:if I wanna make url like this www.abc.com/username/projectname ( which username and projectname are depend on the user ) I got two solution,first one is use Regular Expressions like (r'/(w+)/(w+)', IndexHandler) and trying to get username...

HTTP-Compression in rails not working for JSON-responses

ruby-on-rails,ruby,http,nginx,http-compression
I have rails 3.2.1 application and nginx. In nginx configurations I set gzip on;, and compressing works for pages, css, js files. But it does not work for JSON responses. As I found the solution for rails is to add: config.middleware.use Rack::Deflater into application.rb. And it helps: before response was...

check if nginx pseudo streaming is working

nginx,video-streaming,mp4,pseudo-streaming
i have nginx 1.9 version installed, and enabled mp4 ngx_http_mp4 modules,and i configured the setting below. location /video/ { mp4; mp4_buffer_size 1m; mp4_max_buffer_size 5m; mp4_limit_rate on; mp4_limit_rate_after 30s; } but when i use jwplayer to play the mp4 file and checking it using live-http-header, when i jump to different time:...

Roundcube - Nginx does not redirect to .php file automatically

php,ssl,nginx,roundcube
EDITED! I set up a mail server on Debian 7 with Nginx, Postfix, Postfixadmin, Dovecot and Roundcube. I tried to create an alias to use the SSL certificate of my domain example.org (of course, the domain here is an example) for the webmail. When accessing the following URL https://example.org/support/webmail/ -...

Brand new Ubuntu 14.04.2 Docker container + Nginx: connection refused on port 80

ubuntu,nginx,docker
I followed the instructions at Digital Ocean's "How To Install Nginx on Ubuntu 14.04 LTS", which states that Nginx should be running as soon as it is installed, but the following Dockerfile: FROM ubuntu:14.04.2 RUN apt-get update -y RUN apt-get -y install curl RUN apt-get -y install nginx RUN curl...

Unable to serve multiple rails applications with Nginx + Unicorn

ruby-on-rails,nginx,unicorn
I know this is a very common issue, but I've been struggling days with a strange one this time: I want to serve two Rails 4 apps on the same VPS (ubuntu 14.04). I followed this guide for one app with success. My app1 is working fine. But not app2....

Nginx block access to referring url

linux,nginx,dns
I've discovered a domain is pointing to my servers IP address as an A-record. I've tried to implement various measures to have have it blocked. I can block it accessing assets on the server i.e loading JS/CSS files and I can block it when a link is accessed from within...

Not able to access Server-Sent-Events over Mobile 3g Network

nginx,https,proxy,server-sent-events
I am having an issue with Server Sent events. My endpoint is not available on mobile 3G network. One observation I have is that a https endpoint like the one below which is available on my mobile network. https://s-dal5-nss-32.firebaseio.com/s1.json?ns=iot-switch&sse=true But the same endpoint when proxy passed using an nginx and...

Converting .htacess to nginx

.htaccess,nginx
The following is the .htaccess, RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] I used winginx to the get nginx rewrite which is, rewrite ^/(.+)$ /index.php?url=$1 last; But it not working the desired. The original URL is: http://xxxx/foo/info/getinfo/123/ The converted URL should be: http://xxx/foo/index.php?url=info/getinfo/123/...

Cannot access site from host machine on a vagrant virtual machine

php,nginx,vagrant
I setup a nginx+mysql puphpet/vagrant image, with a virtual host "test.com". I mapped test.com to 192.168.56.101 on the host machine, and put an index.php file inside the test folder in /var/www/test. However, when I try opening the browser at the address test.com on the host machine I get no response....

Nginx proxy_pass to a variable url

nginx
I am new to Nginx. As I know, we can configure proxy_pass url in nginx.conf like: location /test { proxy_pass http://10.10.10.10:10000; } But now, I need to proxy_pass to a variable url, we could get this url in http request header or request body(for example). How could I implement this?...

nginx - how to use 'try_files' and an 'index' statement in the same directory?

nginx
Both landing.php and all the other pages of my site are in the same directory. I want to be able to access both, however if I have a try_files statement as well as an index statement, I get a 404 error when accessing the index page. Is there a way...

Django + Gunicorn + Nginx: Bad Request (400) in Debug=True

python,django,nginx,gunicorn
I'm trying to run my Server with Django + Nginx + Gunicorn. On the development Server, everything went fine. But on the production Server, gunicorn always returns a Bad Request (400). I'm aware that I need to set my ALLOWED_HOSTS variable, and I did. I tried the correct domain, an...

Niginx location with cache for a specific url with params

caching,nginx
I'd like to use nginx cache for a specific url only The url is /ajax/airport and must contain the parameter ?geoloc=1. Cache is working fine, the only issue I'm facing is to get it working for an url containing the given parameters. Here is my nginx site.conf file: server {...

502 bad gateway error when reloading PHP-FPM

php,nginx
I have a problem with PHP-FPM on Debian when trying to reload PHP-FPM configuration with PHP script that runs sudo service php5-fpm reload which will reload the same php-fpm process on which the script is running. The problem is that I get "502 Bad gateway" on the moment when the...

Nginx, how to allow DOMAIN:PORT and IP:PORT requests

nginx
What's the proper way to configure Nginx to allow DOMAIN:PORT requests like this: http://example.com:8080/?a=xxx&b=yyy&c=zzz over TCP or UDP And IP:PORT requests like this: http://1.2.3.4:8086/?a=xxx&b=yyy&c=zzz over TCP or UDP Nginx also must allow domain requests like these, which already work correctly on my setup: http://example.com/home http://example.com/work over TCP For the IP:PORT...

Gunicorn and Flask blueprints

python,nginx,flask,gunicorn
I'm using Gunicorn (on nginx) with Flask. Let's say I have two Python files, linked with a Flask Blueprint: app.py and api.py where api.py has the url prefix /api. Why is it that any routes in app.py work although all Blueprinted (i.e. /api) routes return 404s? app.py looks something like...

url extension remove with php

php,redirect,nginx
I have a dilemma here... At the moment I'm launing a website and there are a lot of old url that needs to be redirected to it's new url without .stm extension. And the new site is running Durpal. Ex. http://www.foo.com/foo/bar.stm --> http://www.foo.com/foo/bar So I went looking more into nginx.conf...

LEMP installation with phpmyadmin

php,mysql,nginx,phpmyadmin
I tried many tutorials online, and need help to sort this out. nginx is installed, but http://localhost/ returns a bin file to be saved Here is the site-available/default file. ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files...

Persistent session in glassfish behind nginx proxy

java,session,nginx,proxy,glassfish
I am running a glassfish webserver behind a nginx proxy (which resolves domains). I want to store @SessionScoped data on the Webserver. My problem is, that nginx opens a new session everytime it connects to glassfish and that session is in no way connected to the client. The client itself...

Nginx redirect http subdomains to https

ubuntu,redirect,ssl,nginx,rewrite
I have one domain with 3 subdomains: - example.com (main domain) - api.example.com - blog.example.com - support.example.com (just a cname to point to zendesk) And I have this 3 configuration on my Nginx: api # HTTP server server { listen 80; server_name api.example.com; return 301 https://api.example.com$request_uri; } # HTTPS server...

php-fpm error “no input file specified” with Docker

php,nginx,docker,php-fpm
I am trying to setup a docker container for php-fpm. But encountering this error when visiting the web directory configured on localhost. I have been stuck here for over 5 hours. Here is my Dockerfile: FROM centos:latest WORKDIR /tmp RUN yum -y update RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm; rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm...

Subrequests are not sent or the request hangs

c,nginx
I'm trying to write my own module in C (it has to be C) for Nginx 1.7.12. It is meant to send additional request to another server, when proxied request arrives to Nginx. For this I've created two locations in config: location = / { proxy_pass $backend_url; } location /internal_url...

Another nginx reverse proxy issue

ssl,nginx,reverse-proxy
I'm putting together an nginx reverse proxy. Here is a working nginx conf file snippet: upstream my_upstream_server { server 10.20.30.40:12345; } server { server_name ssl-enabled.example.com; listen 443 ssl; ssl_certificate /etc/ssl/server.crt; ssl_certificate_key /etc/ssl/server.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location / { proxy_pass http://my_upstream_server/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP...

How to “remove” indexed pages in Google and AngularJS

angularjs,nginx,seo,google-index
I have an AngularJS 1.0.7 web application. Some months ago I sent a sitemap.xml file to Google, so the urls are indexed. Now, I would like to upload a new sitemap file with some updates on those URLs. I mean, the pages are the same but the urls have changed...

php5enmod mcrypt with Puppet

php,nginx,ubuntu-14.04,puppet
Another Puppet related question. As part of my installation with Puppet, I'm installing: - Ubuntu 14.04.2 LTS PHP5-FPM Nginx MySQL etc As part of the PHP class I have the following: - package {[ 'php5-fpm', 'php5-mysql', 'php5-cli', 'php5-mcrypt', 'php5-curl', ]: ensure => present, require => Exec['apt-get update'], } This part...

nginx+PHP+Windows .php script not running the lines where there is no error

php,nginx
I am trying to run this simple PHP script in nginx which has one line without any error and a line with a deliberate error. <?php echo "ABCD"; echo "DEFG; ?> My nginx.conf has the following #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;...

How to properly deploy angular application (based on ngBoilerplate and using nginx)?

javascript,angularjs,nginx,deployment,ngboilerplate
I have found, that ngBoilerplate was extremly easy for making first steps in webdevelopment based on angular. Right know I am trying to prepare my deployment pipeline, so I use github, travis-ci and dockerized nginx image. I thought that to properly deploy my simple angular website I just have to:...