question stringlengths 11 28.2k | answer stringlengths 26 27.7k | tag stringclasses 130
values | question_id int64 935 78.4M | score int64 10 5.49k |
|---|---|---|---|---|
I'm developing an ember.js app with a laravel backend. I'm trying to return http error codes with php if something goes awry. I've noticed that when issue a PUT request and return a 400 status code, my CORS headers get ignored by my conf file which breaks my ember frontend. I have no idea why the PUT/400 code combo mak... | For nginx >= 1.7.5
Append "always" to the header definition:
add_header 'Access-Control-Allow-Origin' '*' always;
For nginx < 1.7.5
According to the nginx official document of ngx_header_module, the add_header can't work when response code is 400
syntax: add_header name value;
default: —
context: http, serv... | NGINX | 20,414,669 | 52 |
I'm trying to find tutorials on how to build a module/plugin for Nginx web server.
Can someone help please, I just can't seem to find the appropriate tutorials.
| Quoting from the documentation:
Evan Miller has written the definitive guide to Nginx module development.
But some parts of it are a little out of date. You've been warned.
A github search turned up the Nginx Development Kit. It seems to be
more up to date.
From my own personal experience, Evan Miller's guide wa... | NGINX | 1,187,314 | 52 |
I'm trying to follow this Ansible tutorial while adjusting it for Ubuntu 16.04 with php7. Below this message you'll find my Ansible file. After running it and trying to visit the page in the browser I get a 404, and the following in the nginx error logs:
2016/10/15 13:13:20 [crit] 28771#28771: *7 connect() to
unix:/... | Had the same problem.
Solution is very easy.
In nginx conf file you are trying upstreaming to
unix:/var/run/php7.0-fpm.sock
Correct path is
unix:/var/run/php/php7.0-fpm.sock
There is a mention about this in the documentation
Nginx communicates with PHP-FPM using a Unix domain socket. Sockets
map to a path on the fi... | NGINX | 40,059,745 | 51 |
The below is my nginx configuration file located in /etc/nginx/nginx.conf
user Foo;
worker_processes 1;
error_log /home/Foo/log/nginx/error.log;
pid /home/Foo/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
access_log /home/Foo/log/nginx/access.log;
server {
listen 80;
... | You might need to fire it with sudo
sudo nginx -t
| NGINX | 34,258,894 | 51 |
For example, I want to do this:
if ($http_user_agent ~ "MSIE 6.0" || $http_user_agent ~ "MSIE 7.0" (etc, etc)) {
rewrite ^ ${ROOT_ROOT}ancient/ last;
break;
}
instead of this:
if ($http_user_agent ~ "MSIE 6.0") {
rewrite ^ ${ROOT_ROOT}ancient/ last;
break;
}
if ($http_user_agent ~ "MSIE 7.0") {
rewri... | Edit:
As Alexey Ten didn't add a new answer, I'll edit mine to give his better answer in this case.
if ($http_user_agent ~ "MSIE [67]\.")
Original answer:
Nginx doesn't allow multiple or nested if statements however you can do this :
set $test 0;
if ($http_user_agent ~ "MSIE 6\.0") {
set $test 1;
}
if ($http_user_ag... | NGINX | 29,756,330 | 51 |
I use nginX/1.6 and laravel when i posted data to server i get this error 413 Request Entity Too Large. i tried many solutions as bellow
1- set client_max_body_size 100m; in server and location and http in nginx.conf.
2- set upload_max_filesize = 100m in php.ini
3- set post_max_size = 100m in php.ini
After restarting ... | Add ‘client_max_body_size xxM’ inside the http section in /etc/nginx/nginx.conf, where xx is the size (in megabytes) that you want to allow.
http {
client_max_body_size 20M;
}
| NGINX | 26,608,606 | 51 |
I'm trying to setup an application webserver using uWSGI + Nginx, which runs a Flask application using SQLAlchemy to communicate to a Postgres database.
When I make requests to the webserver, every other response will be a 500 error.
The error is:
Traceback (most recent call last):
File "/var/env/argos/lib/python3.3/... | The issue ended up being uwsgi's forking.
When working with multiple processes with a master process, uwsgi initializes the application in the master process and then copies the application over to each worker process. The problem is if you open a database connection when initializing your application, you then have mu... | NGINX | 22,752,521 | 51 |
At my ubuntu server, I install nginx and setup virtual host using this article.
https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3
The virtual host's domain name is like www.example.com. When I go to www.example.com, I can see my application's index pa... | You need to remove the file default, located in /etc/nginx/sites-enabled:
rm /etc/nginx/sites-enabled/default
Then restart nginx:
service nginx reload
| NGINX | 19,215,641 | 51 |
We use Nginx as a reverse proxy with this setup:
upstream frontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
[...]
}
server {
location / {
proxy_pass http://frontends;
[...]
}
[...]
}
As part of the access log,... | First add new logging format
log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name $host to: $upstream_addr: $request $status upstream_response_time $upstream_response_time msec $msec request_time $request_time';
Example output:
[18/Nov/2019:10:08:15 -0700] <request IP> - - - <config host> <... | NGINX | 18,627,469 | 51 |
As someone new to the Java EE ecosystem, I'm confused with these products which share a tremendous amount of keywords. And half of them come from Apache software foundation.
Can someone address me with a brief distinctive explanation for each of them?
| Jetty and Tomcat are web-containers, while Geronimo, Glassfish and JBoss support the whole J2EE stack (more or less). And, tataaa, they use/include Tomcat or Jetty for web-containers. The most important part of a fullblown J2EE server besides the web-container used to be the EJB-container allowing for deployment of EJB... | NGINX | 4,712,689 | 51 |
I first got my nginx docker image:
docker pull nginx
Then I started it:
docker run -d -p 80:80 --name webserver nginx
Then I stopped it:
docker stop webserver
Then I tried to restart it:
$docker run -d -p 80:80 --name webserver nginx
docker: Error response from daemon: Conflict. The container name "/webserver" is al... | It is because
you have used --name switch.
container is stopped and not removed
You find it stopped
docker ps -a
You can simply start it using below command:
docker start webserver
EDIT: Alternatives
If you want to start the container with below command each time,
docker run -d -p 80:80 --name webserver nginx
th... | NGINX | 42,760,216 | 50 |
I try to deploy a django project with Nginx and Gunicorn with this tutorial. i did all to-dos but, when i create /etc/nginx/sites-available/myproject file with below code:
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /h... | You're getting the path wrong for proxy_params 99% of the time (From my experience), the default location for the proxy_params file is /etc/nginx/proxy_params but that doesn't seem to be the same for you.
The proxy_params file contains the following:
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_... | NGINX | 42,589,781 | 50 |
I'm working through https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04. I've completed the tut but I'm getting a 502 error.
My nginx server block configuration file:
server {
listen 80;
server_name 198..xxx.xxx.xxx mysite.org;
location = /favicon.ico... | That warning with the nginx.pid file is a know bug (at least for Ubutnu if not for other distros as well). More details here:
https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864
Workaround (on a ssh console, as root, use the commands bellow):
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecSta... | NGINX | 42,078,674 | 50 |
I am trying to run nginx (reverse proxy) as a windows service so that it's possible to proxy a request even when a user is not connected.
I searched a lot around and found winsw that should create a service from an .exe file (such as nginx).
i found many tutorials online saying to create an xml file as following
<servi... | Just stumbled here and managed to get things working with this free open source alternative: https://nssm.cc/
It basically is just a GUI to help you create a service. Steps I used:
Download NGinx (http://nginx.org/en/download.html) and uzip to C:\foobar\nginx
Download nssm (https://nssm.cc/)
Run "nssm install nginx" ... | NGINX | 40,846,356 | 50 |
I have a pod that responds to requests to /api/
I want to do a rewrite where requests to /auth/api/ go to /api/.
Using an Ingress (nginx), I thought that with the ingress.kubernetes.io/rewrite-target: annotation I could do it something like this:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myapi-ing
... | I don't know if this is still an issue, but since version 0.22 it seems you need to use capture groups to pass values to the rewrite-target value
From the nginx example available here
Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target are not backwards compa... | NGINX | 47,837,087 | 49 |
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
I am facing this error on mac while trying to run this command docke... | Put this line --platform linux/amd64 after docker run. It works for me, using Macbook M1.
| NGINX | 72,152,446 | 49 |
I want to add/remove servers in my nginx running inside a docker container
I use ADD command in Dockerfile to add my nginx.conf to /etc/nginx dir.
# Copy a configuration file from the current directory
ADD nginx.conf /etc/nginx/
then in my running nginx container that have a conf like this
# List of application server... | restarting the container is not advisable when you initialize Docker Swarm because it may remove the nginx service. So if you need an alternative aside docker restart; You can go inside the container and just run nginx -s reload
For example, in docker env, if you have the container named nginx
docker exec <nginx_contai... | NGINX | 26,291,260 | 49 |
I have a CentOS server. System is nginx/php-fpm. It has 16GB RAM.
CPUs : 8
CPU Frequency: 2660.203 MHz
Why am I getting this error in my error log?
php-fpm/error.log:
[02-Aug-2014 17:14:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or
pm.min/max_spare_servers), spawning 8 children, the... | It is a tough cookie because there could be numerous factors involved. The first problem with your config is the max_children is ridiculously high. If each child process is using 50MB then 50 x 32768 would easily deplete 16GB.
A better way to determine max_children is to find out how much each child process uses, then... | NGINX | 25,097,179 | 49 |
I configured nginx as reverse proxy to my node.js application for file uploads with proxy_pass directive.
It works, but my problem is that nginx waits for the whole file body to be uploaded before passing it to the upstream. This causes problems for me, because I want to track upload progress at my application. Any ide... | There is no way to (at least as of now). Full request will be always buffered before nginx will start sending it to an upstream. To track uploaded files you may try upload progress module.
Update: in nginx 1.7.11 the proxy_request_buffering directive is available, which allows to disable buffering of a request body. ... | NGINX | 12,282,342 | 49 |
I'm building a Node.js applications and I'm using nginx as a reverse proxy. My application has some static files I need to serve and a Socket.io server.
I know that I can serve static files directly with Express (using express.static middleware). Also I can point nginx directly to the directory where my static files a... | for development: express, mainly because of flexibility it provides... you can change your static location and structure very easily during development
for production: nginx, because its much much faster. Node/express are good for executing logic, but for serving raw content... nothing can beat nginx. You also get addi... | NGINX | 44,796,056 | 48 |
I have to add ssl (https) for a website, I was given a SSL.CSR and a SSL.KEY file. I 'dos2unix'ed them (because they have trailing ^M) and copied them to the server(CSR -> mywebsite.crt, KEY -> mywebsite.key). I did the following modification to nginx.conf:
@@ -60,8 +60,13 @@
}
server {
- listen ... | You should never share your private key. You should consider the key you posted here compromised and generate a new key and signing request.
You have a certificate request and not an actual signed certificate. You provide the request ('CSR') to the signing party. They use that request to create a signed certificate ('C... | NGINX | 21,870,644 | 48 |
I'm having some trouble defining a rule to cache my static files. I've found this solution:
location ~* \.(ico|js|css|png|gif|jpe?g)$ {
expires 7d;
}
which actually looks like what I need. The problem is, if I include this code into my NGINX.conf, no static files are delivered anymore and my site is blank. Any ideas... | Put this before your other location block:
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
}
That should work.
You could also use this:
## All static files will be served directly.
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|... | NGINX | 19,515,132 | 48 |
I am trying to enable client certificate authentication in nginx where the certificates have been signed by an intermediate CA. I am able to get this working fine when using a certificate signed by a self-signed root CA; however, this does not work when the signing CA is an intermediate CA.
My simple server section lo... | Edit: I had also this "problem", solution and explanation is at the bottom of the text.
It seemed like nginx doesn't support intermediate certificates. My certs self created: (RootCA is selfsigned, IntrermediateCA1 is signed by RootCA, etc.)
RootCA -> IntermediateCA1 -> Client1
RootCA -> IntermediateCA2 -> Client2
I... | NGINX | 8,431,528 | 48 |
I'm using apache+mod_wsgi for django.
And all css/js/images are served through nginx.
For some odd reason, when others/friends/colleagues try accessing the site, jquery/css is not getting loaded for them, hence the page looks jumbled up.
My html files use code like this -
<link rel="stylesheet" type="text/css" href=... | I think using root in location block is incorrect. I use alias and it works fine, even without re-configuring django.
# django settings.py
MEDIA_URL = '/static/'
# nginx server config
server {
...
location /static {
autoindex on;
alias /opt/aa/webroot/;
}
}
Hope this makes t... | NGINX | 2,451,739 | 48 |
EDIT: Updated the text in general to keep it shorter and more concise.
I am trying to configure HTTPS when I run npm run dev so I can test MediaStream and alike locally (for which browsers require me to provide HTTPS).
I am trying to configure it through nuxt.config.js but without any success.
Here is my nuxt.config.js... | HTTPS on local dev - NUXT style
Solution is described in NUXT documentation:
https://nuxtjs.org/api/configuration-server/#example-using-https-configuration
This may be achieved with:
Go to project main dir;
Create private and public key;
openssl genrsa 2048 > server.key
chmod 400 server.key
openssl req -new -x509 -no... | NGINX | 56,966,137 | 47 |
So, I found an answer to removing the .html extension on my page, that works fine with this code:
server {
listen 80;
server_name _;
root /var/www/html/;
index index.html;
if (!-f "${request_filename}index.html") {
rewrite ^/(.*)/$ /$1 permanent;
}
if ($request_uri ~* "/index.html"... | The "Holy Grail" Solution for Removing ".html" in NGINX:
UPDATED ANSWER: This question piqued my curiosity, and I went on another, more in-depth search for a "holy grail" solution for .html redirects in NGINX. Here is the link to the answer I found, since I didn't come up with it myself: https://stackoverflow.com/a/329... | NGINX | 38,228,393 | 47 |
I have a really basic nginx setup which is failing for some reason;
server {
listen 80;
server_name librestock.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/david/StockSearch/stocksearch;
}
location / {
include proxy_params;
... | You need the http:// prefix on your unix: path, as in:
proxy_pass http://unix:/home/david/StockSearch/stocksearch/stocksearch.sock;
See
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
| NGINX | 32,992,908 | 47 |
I have a website which should only be reachable over HTTPS except one URL-pattern (because I have on some pages http-iframe's and I would like to avoid security warnings)
E.g. this pages should be redirected to https:
http://example.com
http://example.com/a/this-is-an-article
http://example.com/v/this-is-a-video
This ... | If the iframe pages are always in the same directory, simple prefix locations could be used.
server {
listen 443;
location /l/ { # redirect https iframe requests to http server
return 301 http://$server_name$request_uri;
}
# ...
}
server {
listen 80;
location / { # the default locat... | NGINX | 27,857,334 | 47 |
Currently every invalid page is 500 (Internal Server Error) because I probably messed up with my server block configuration.
I decided to shut down my website a while ago and created a simple one-page, thank-you homepage. However old links and external sites are still trying to access other parts of the site, which no ... | Setting the error page to the home page like this
error_page 404 /index.html;
has a small problem, the status code of the home page will be "404 not found", if you want to load the home page with a "200 ok" status code you should do it like this
error_page 404 =200 /index.html;
This will convert the "404 not found" e... | NGINX | 19,487,365 | 47 |
I have installed nginx on Ubuntu 12.04. However, nginx does not seem to follow symlinks. I understand that there is a config change required for this but I am not able to find where to make the change. Any help appreciated.
| Have a look at the following config option from nginx docs:
Syntax:
disable_symlinks off;
disable_symlinks on |
if_not_owner [from=part];
Default: disable_symlinks off;
Context: http, server, location
This directive appeared in version 1.1.15.
| NGINX | 12,624,358 | 47 |
I can specify custom log format for access_log on Nginx, but it doesn't work for error_log.
Is there anyway to achieve this?
| You can't specify your own format, but in nginx build-in several level's of error_log-ing.
Syntax: error_log file [ debug | info | notice | warn | error | crit ]
Default: ${prefix}/logs/error.log
Specifies the file where server (and fastcgi) errors are logged.
Default values for the error level:
in the main section - ... | NGINX | 4,246,756 | 47 |
I'm trying to get webpack-dev-server running inside a Docker container then accessing it through a NGINX host. The initial index.html loads but the Web Sockets connection to the dev server cannot connect.
VM47:35 WebSocket connection to 'ws://example.com/sockjs-node/834/izehemiu/websocket' failed: Error during WebSock... | Proxy pass should be ip and port of your webpack-dev-server container and you need proxy_redirect off;
location /sockjs-node {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://node:8080;
proxy_redirect off;
... | NGINX | 40,516,288 | 46 |
I'm hosting a website behind a Cloudflare proxy, which means that all requests to my server are over port 80, even though Cloudflare handles HTTP (port 80) and HTTPS (port 443) traffic.
To distinguish between the two, Cloudflare includes an X-Forwarded-Proto header which is set to "http" or "https" based on the user's... | The simplest way to do this is with an if directive. If there is a better way, please let me know, as people say the if directive is inefficient. Nginx converts dashes to underscores in headers, so X-Forwarded-Proto becomes $http_x_forwarded_proto.
server {
listen 80;
server_name example.com; # Replace this wit... | NGINX | 26,223,733 | 46 |
I have some error with subj. Server doesn't high loaded: ~15% CPU, there are several Gb of memory, HDD is not buisy. But error 502 throws approximately in 3% of cases.
Programs: Debian 6, nginx/0.7.62, php5-fpm (5.3.3-1).
In error.log of nginx is this error:
connect() to unix:/var/run/php5-fpm.sock failed
State of ph... | The issue is socket itself, its problems on high-load cases is well-known. Please consider using TCP\IP connection instead of unix socket, for that you need to make these changes:
in php-fpm pool configuration replace listen = /var/run/php5-fpm.sock with listen = 127.0.0.1:7777
in /etc/nginx/php_location replace fastc... | NGINX | 10,470,109 | 46 |
I want to test nginx subdomains before uploading config to the server. Can i test it on localhost? I try
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8080;
}
}
server {
listen 80;
server_name sub.localhost;
location / {
... | Yes, add '127.0.0.1 sub.localhost' to your hosts file. That sub has to be resolved somehow. That should work.
Then once you're ready to go to the net, yes, add an a or cname record for the subdomain sub.
When I use proxy_pass I also include the proxy.conf from nginx.
http://wiki.nginx.org/HttpProxyModule
| NGINX | 10,095,219 | 46 |
I work for a rather busy internet site that is often gets very large spikes of traffic. During these spikes hundreds of pages per second are requested and this produces random 502 gateway errors.
Now we run Nginx (1.0.10) and PHP-FPM on a machine with 4x SAS 15k drives (raid10) with a 16 core CPU and 24GB of DDR3 ram. ... | This should fix it...
You have:
fastcgi_buffers 4 256k;
Change it to:
fastcgi_buffers 256 16k; // 4096k total
Also set fastcgi_max_temp_file_size 0, that will disable buffering to disk if replies start to exceeed your fastcgi buffers.
| NGINX | 8,772,015 | 46 |
I have an application written in Angular 7 that I am deploying to a Docker container with NGINX. When I run the container, everything works perfectly except that if i Refresh the page in the browser (F5) I get an NGINX 404 error page.
Here is my nginx.conf file from which you can see ive tried "try_files"
user nginx;
... | With a refresh on Angular app, we need to tell nginx web server to first look at the index.html file if the requested route exists or not before showing the error page. This is working fine for me:
nginx.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/htm... | NGINX | 56,213,079 | 45 |
I'm out of ideas and I need help please!
I create my SSL using Openssl with this:
openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout key.pem -out cert.pem -days 3650
The cert.pem looks like this:
-----BEGIN CERTIFICATE-----
cert
-----END CERTIFICATE-----
The key.pem looks like this:
-----BEGIN PRIVATE KEY----... | A "normal" certificate, once encoded in PEM will look like this:
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
(the ... is Base64 encoding of a DER structure)
This is normally (with the associated key, typically in separate file) the thing needed by any TLS enabled application when it wants to show its ide... | NGINX | 51,899,844 | 45 |
I have two docker containers: Nginx and App.
The app container extends PHP-fpm and also has my Laravel Code.
In my docker-compose.yml I'm doing:
version: '2'
services:
nginx:
build:
context: ./nginx
dockerfile: ./Dockerfile
ports:
- "80:80"
links:
... | Make your Dockerfile something as below -
FROM php:7-fpm
WORKDIR /var/www
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && docker-php-ext-install mcrypt pdo_mysql
ADD . /var/www
RUN chown -R www-data:www-data /var/www
This makes directory /var/www owned by www-data which is the default user for ... | NGINX | 48,619,445 | 45 |
I'm attempting to deploy my create-react-app SPA on a Digital Ocean droplet with Ubuntu 14.04 and Nginx. Per the static server deployment instructions, I can get it working when I run serve -s build -p 4000, but the app comes down as soon as I close the terminal. It is not clear to me from the create-react-app repo rea... | One of the major benefits of React (and Create React App) is that you don't need the overhead of running a Node server (or proxying to it with Nginx); you can serve the static files directly.
From the Deployment documentation you've linked to, Create React App describes what to do:
npm run build creates a build direct... | NGINX | 46,880,853 | 45 |
I am making a practice web service (client's artbook display web site) The client can upload artbook images to the server.
But I get the following error when the client uploads too many images
413 Request Entity Too Large
I tried adding client_max_body_size 100M; in nginx.conf
#user nobody;
#Defines which Linux syste... | You've fixed the issue on your HTTP server, but your HTTP server is set to 301 redirect to your HTTPS server... your HTTPS server does not have client_max_body_size configured, so it is defaulting to 1M & causing this 413 (Request Entity Too Large) error.
To fix this issue, you simply need to add client_max_body_size t... | NGINX | 36,994,828 | 45 |
I have got my EV SSL Certificate. I am following tutorials on how to use my certificate with NGINX on Ubuntu
When I am trying to restart my nginx, I get:
**invalid number of arguments in "ssl_certificate_key" directive in /etc/nginx/sites-enabled/default
What I did so far:
sudo nano /etc/nginx/sites-enabled/default
... | It looks like you may be missing a semicolon at the end of the ssl_certificate_key line.
| NGINX | 33,001,692 | 45 |
basically an server instance is running at
somesite.com/production/folder/here?param=here&count=1
I want to point someite.com/demo to /production/folder/here so when user types somesite.com/production/demo?param=here it will work without redirecting to /production/folder/here
| server {
server_name example.com;
root /path/to/root;
location / {
# bla bla
}
location /demo {
alias /path/to/root/production/folder/here;
}
}
If you need to use try_files inside /demo you'll need to replace alias with a root and do a rewrite because of the bug explained here
| NGINX | 21,399,789 | 45 |
How can I compile my Lua scripts into a single executable file, while also gaining the super fast performance benefits of LuaJIT?
Background:
My Lua scripts are for a web application I created (e.g. to host http://example.com)
My current technology stack is NGINX (web server), Lua/LuaJIT (language to retrieve dynamic ... | Translate all of the Lua source code files to object files and put them in a static library:
for f in *.lua; do
luajit -b $f `basename $f .lua`.o
done
ar rcus libmyluafiles.a *.o
Then link the libmyluafiles.a library into your main program using -Wl,--whole-archive -lmyluafiles -Wl,--no-whole-archive -Wl,-E.
This ... | NGINX | 11,317,269 | 45 |
I was running a vuejs app on its own dev server, now I can access the site by public IP of machine, But after pointing it with a domain using nginx its showing an error loop in console
error in console
Invalid Host header
[WDS] Disconnected!
Due to this the script,style injection and auto reload not working.
config of ... | I believe you need to change vue.config.js
module.exports = {
devServer: {
disableHostCheck: true
}
}
| NGINX | 51,084,089 | 44 |
I'm using nginx as a load balancer in front of several upstream app servers and I want to set a trace id to use to correlate requests with the app server logs. What's the best way to do that in Nginx, is there a good 3rd party module for this?
Otherwise a pretty simple way would be to base it off of timestamp (possibl... | nginx 1.11.0 added the new variable $request_id which is a unique identifier, so you can do something like:
location / {
proxy_pass http://upstream;
proxy_set_header X-Request-Id $request_id;
}
See reference at http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_id
| NGINX | 17,748,735 | 44 |
I'm trying to set up a simple virtual host, serving only static files. Trouble is, directing the browser to (in this case) jorum.dev displays the default nginx welcome page, as opposed to jorum.dev/index.html.
Nginx was installed using Homebrew on Mac OS X Mountain Lion.
hosts
127.0.0.1 jorum.dev
jorum.dev
serve... | the debian/ubuntu nginx package comes with a default sites-available that takes over the default host dispatch. Simply remove the default link and it should load your site instead.
another gotcha, the debian/ubuntu nginx package also comes with a default index value for the default server in the default site that read... | NGINX | 14,460,935 | 44 |
When you turn on the nginx rewrite log with rewrite_log on;, where does the system actually log that info? It doesn't seem to be in the documentation, and a decent search through google doesn't turn anything up.
I have also tried enabling and looking in both the access and error logs. No luck.
| If rewrite_log on; is used then the rewrite information will be logged to error_log at notice level. There is no separate log file.
| NGINX | 9,900,443 | 44 |
How to I get rid of all the below errors in nginx. I do not have a favicon.ico
2012/03/11 17:13:25 [error] 959#0: *116 open() "/usr/local/nginx/html/favicon.ico" failed (2: No such file or directory), client: 111.68.59.75, server: 127.0.0.1, request: "GET /favicon.ico HTTP/1.1"
I would imagine some line in nginx co... | location = /favicon.ico {
log_not_found off;
}
| NGINX | 9,657,065 | 44 |
My original question was how to enable HTTPS for a Django login page, and the only response, recommended that I - make the entire site as HTTPS-only.
Given that I'm using Django 1.3 and nginx, what's the correct way to make a site HTTPS-only?
The one response mentioned a middleware solution, but had the caveat:
Djang... | For the 2nd part of John C's answer, and Django 1.4+...
Instead of extending HttpResponseRedirect, you can change the request.scheme to https.
Because Django is behind Nginx's reverse proxy, it doesn't know the original request was secure.
In your Django settings, set the SECURE_PROXY_SSL_HEADER setting:
SECURE_PROXY_... | NGINX | 8,153,875 | 44 |
I'm serving Angular 2 application with nginx using location section this way:
location / {
try_files $uri $uri/ /index.html =404;
}
try_files directive tries to find the requested uri in root directory and if it fails to find one it simply returns index.html
How to disable caching of index.html file?
| Found a solution using nginx named locations:
location = / {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
location / {
gzip_static on;
try_files $uri @index;
}
location @index {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
| NGINX | 41,631,399 | 43 |
I'm unfortunately not much of a system administrator and have come upon a problem that has me banging my head against the wall.
The short story is that I'm running Nginx on EC2 (Ubuntu 14.04.4 LTS) to (a) host my company's marketing site (https://example.com, which incidentally is Wordpress) and (b) serve as a reverse ... | I was able to solve this today and wanted to post the solution in case others run into the same issue.
It turns out that the problem was related to SNI after all. I found this ticket on nginx.org:
https://trac.nginx.org/nginx/ticket/229
Which led me to the proxy_ssl_server_name directive:
http://nginx.org/r/proxy_ssl_s... | NGINX | 38,375,588 | 43 |
I want to run a script, right after running
`docker-compose up -d`
Here is my snippet of docker-compose.yml . The other settings are mysql server, redis...etc....but they are not causing any problems
web:
image: nginx
container_name: web-project
volumes:
- ./code:/srv
working_dir: /srv/myweb
extra_ho... | command overrides the default command.
That's the reason your container stops: nginx never starts.
At the end of your script you have to run nginx
#!/bin/bash
echo running post install scripts for web..;
cd /srv/myweb
npm install
composer self-update
composer update
nginx
By the way, I suggest you to change your scri... | NGINX | 33,009,825 | 43 |
I have two docker containers with nginx. container1 is linked to container2. Docker then adds an entry to /etc/hosts which I entered into the nginx configuration like so:
server {
location ~ ^/some_url/(.*)$ {
proxy_pass http://container1/$1;
}
}
I can ping container1 from container2, but nginx cannot ... | Use an upstream block instead of the container name directly
upstream backend {
server container1;
}
server {
location ~ ^/some_url/(.*)$ {
proxy_pass http://backend/$1;
}
}
This should allow normal name resolution to occur providing a way to easily use docker links with nginx.
| NGINX | 28,028,789 | 43 |
My host's file maps 127.0.0.1 to localhost.
$ curl -I 'localhost'
curl: (7) Failed to connect to localhost port 80: Connection refused
And then
$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.2.4
Date: Wed, 09 Apr 2014 04:20:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Oct 2012 21:48:3... | Since you have a ::1 localhost line in your hosts file, it would seem that curl is attempting to use IPv6 to contact your local web server.
Since the web server is not listening on IPv6, the connection fails.
You could try to use the --ipv4 option to curl, which should force an IPv4 connection when both are available.... | NGINX | 22,952,676 | 43 |
I'm trying to set up SSL on Nginx. It doesn't work, and I am getting the following error in the error log, which is getting passed up from the OpenSSL library which nginx was compiled with. I don't know what that library is, but it's version 0.8.54 of nginx, and I installed it using apt-get on Ubuntu Linux.
2012/02/21 ... | Remove the key pass phrase:
openssl rsa -in key.pem -out newkey.pem
If the certificate and the key are together:
openssl rsa -in mycert.pem -out newcert.pem
openssl x509 -in mycert.pem >>newcert.pem
Source: http://www.madboa.com/geek/openssl/#key-removepass
| NGINX | 9,380,403 | 43 |
What are the advantages of having nginx or another web-server running as a reverse-proxy in front of the Node.JS? What does it provide?
(This question is intended for matters concerning web-apps, not web-pages).
Thank you.
| I think the greatest benefit is that you're then able to use the same port (80) for multiple applications. Otherwise, you'd need a new IP address for each nodejs application you have. Depending on how you set things up, you can also configure different folders and subdomains to different nodejs apps running on differen... | NGINX | 6,763,571 | 43 |
I'm converting my mediawiki site to use nginx as a frontend for static files with apache on the backend for php. I've gotten everything working so far except for when I view the root directory "example.com" it tries to serve a directory listing and gives a 403 error since I have that disabled and don't have an index fi... | I found help in the nginx irc chat.
Basically what I needed to do was use a return instead of rewrite. So I changed this:
location = / {
rewrite "^$" /wiki/Main_Page;
}
to this:
location = / {
return 301 http://www.example.com/wiki/Main_Page;
}
| NGINX | 17,738,088 | 42 |
I am running nginx as reverse proxy for the site example.com to loadbalance a ruby application running in backend server. I have the following proxy_set_header field in nginx which will pass host headers to backend ruby. This is required by ruby app to identify the subdomain names.
location / {
proxy_pass http://r... | You cannot use proxy_pass in if block, so I suggest to do something like this before setting proxy header:
set $my_host $http_host;
if ($http_host = "beta.example.com") {
set $my_host "www.example.com";
}
And now you can just use proxy_pass and proxy_set_header without if block:
location / {
proxy_pass http://ruby... | NGINX | 14,352,690 | 42 |
I'm wondering how do I know if a particular location[s] used to process request in nginx.
E.g.:
# 1
location / {}
# 2
location ~ /[\w\-]+\.html {}
# 3
location ~ /\w+\.html {}
How do I know if URI like /mysite is processed by 3rd location and not 2nd?
I tend to use add_header for this matter:
location / {
add_he... | If you just want to see which block was used, and don't care about returning otherwise valid results, it might be more straight-forward to use return rather than add_header.
location / {
return 200 'location 1';
}
location ~ /(\w+\-)\.html {
return 200 'location 2';
}
location @named {
return 200 'loc... | NGINX | 12,703,702 | 42 |
I'm deploying a Rails app to production. It seems that Puma is fast and handles many of the things I want in a web server.
I'm wondering if I even need to bother with Nginx, and what I'd be missing out on if just used Puma?
| Nginx is a web server and puma is an application server.
Both have their advantages, and you need both.
Some examples:
Static redirects- you could setup your nginx to redirect all http traffic to the same url with https. This way such trivial requests will never hit your app server.
Multipart upload- Nginx is better s... | NGINX | 50,516,699 | 41 |
Im trying to set the ALLOWED-FROM in Nginx but all settings I tried so far resulted in the following Chrome error:
Invalid 'X-Frame-Options' header encountered when loading 'https://domain.com/#/register': 'ALLOW-FROM domain.com' is not a recognized directive. The header will be ignored.
This options I tried are those:... | in Chrome and Safari you need to use Content-Security-Policy
Content-Security-Policy: frame-ancestors domain.com
You can check more details on this site:
https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
| NGINX | 30,731,290 | 41 |
I want to set up Nginx as a reverse proxy for a https service, because we have a special usecase where we need to "un-https" a connection:
http://nginx_server:8080/myserver ==> https://mysecureservice
But what happens is that the actual https service isn't proxied. Nginx does redirect me to the actual service, so the U... | You have to use the proxy_redirect to handle the redirection.
Sets the text that should be changed in the “Location” and “Refresh” header fields of a
proxied server response. Suppose a proxied server returned the header field
“Location:https://myserver/uri/”. The directive
will rewrite this string to “Location: h... | NGINX | 24,520,540 | 41 |
Is there a way to inject a few lines of script etc. for each served php/html/etc. page?
For example some custom javascript after -tag?
I know, you should be able to use lua in nginx but is there a better solution?
I am running multiple different web application behind the nginx, so it feels proper way to do this. I do... | I found the way to do this: http://nginx.org/en/docs/http/ngx_http_sub_module.html
location / {
sub_filter </head>
'</head><script language="javascript" src="$script"></script>';
sub_filter_once on;
}
| NGINX | 19,700,871 | 41 |
Here is my situation: I will have one frontend server running Nginx, and multiple backends servers running Apache + passenger with different rails applications. I am NOT trying to do any load balancing. What I need to do is setup Nginx to proxy connections to specific servers based on the URL. IE, client.example.com sh... | You can match the different URLs with server {} blocks, then inside each server block, you'd have the reverse proxy settings.
Below, an illustration;
server {
server_name client.example.com;
# app1 reverse proxy follow
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-F... | NGINX | 13,240,840 | 41 |
I only want to redirect the root path from domain A to domain B. For example, if user type in https://www.a.com/ or https://www.a.com or http://a.com all redirect to https://www.b.com/, but if user type in https://www.a.com/something/ then it keep there without redirect.
I tried the following:
location / {
return 3... | I got it.
location ~ ^/$ {
return 301 https://www.b.com/;
}
| NGINX | 41,755,100 | 40 |
My application uses nginx, with uWSGI on the server side. When I do a large request (with a response time > 4s), the following appears:
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request _URL_ (ip XX.XX.XX.XX) !!!
uwsgi_response_writev_headers_and_body_do(): Broken pipe
[... | It may be the case that when you upload things, you use chunked encoding.
There is uWSGI option
--chunked-input-timeout,
that by default is 4 seconds (it defaults
to value of --socket-timeout, which is 4 seconds).
Though problem theoretically may lie somewhere else, I suggest you to try
aforementioned options. Plus, an... | NGINX | 36,156,887 | 40 |
NGINX acting as a caching proxy encounters problems when fetching content from CloudFront server over HTTPS:
This is the extract from the NGINX's error log:
2014/08/14 16:08:26 [error] 27534#0: *11560993 SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) wh... | I had the exactly same problem and spent a couple of hours...
I guess you are using older version of nginx (lower than 1.7)?
In nginx 1.7 you can use this directive:
proxy_ssl_server_name on;
This will force nginx to use SNI
Also, you should set the SSL protocols:
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
For earli... | NGINX | 25,329,941 | 40 |
Good morning,
I am using amazon s3 bucket as the image server.
And I want to use a subdomain of my site, how to address this bucket.
eg: a picture is now in: https://s3-sa-east-1.amazonaws.com/nomeBucket/pasta/imag.png, and I access it through this same link.
Would that it were so: imagens.mydomain.com.br / folder / im... | You need to rename your bucket to match the custom domain name (e.g. imagens.mydomain.com.br) and set up that domain as a CNAME to
<bucket-name>.s3.amazonaws.com.
(in your case imagens.mydomain.com.br.s3.amazonaws.com.
The full instructions are available here:
http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHos... | NGINX | 18,765,934 | 40 |
Is it possible to have the 40x and 50x errors served by a single location rule? Something like:
error_page 403 /403.html;
error_page 404 /404.html;
error_page 405 /405.html;
error_page 500 501 502 503 504 /5xx.html;
location ~ /(?:40[345]|5xx)[.]html$ {
root /var/www/default/error;
}
| error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 500 501 502 503 504 /error/5xx.html;
location ^~ /error/ {
internal;
root /var/www/default;
}
http://nginx.org/r/location
http://nginx.org/r/error_page
http://nginx.org/r/root
| NGINX | 13,621,915 | 40 |
I need to write a C++ interface that can read our data structure and provide the o/p based on query using http protocol.
Server Need
It should be able to serve 100 clients at the same time.
Why C++
All code is already written in C++. So we need to just write a http layer in C++. That's why I am choosing C++ instead o... | No one here seems to have addressed the actual question, though some nice work arounds have been offered. I've been able to build C++ modules for nginx with a couple of minor changes.
Change the module source file name to end with .cpp so gcc realizes it is dealing with C++.
Make sure all your Nginx includes (e.g. ngx... | NGINX | 9,083,869 | 40 |
I see the Nginx HttpRewriteModule documentation has an example to rewrite a www-prefixed domain to a non-www-prefixed domain:
if ($host ~* www\.(.*)) {
set $host_without_www $1;
rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
}
How can I do the reverse-- rewrit... | As noted in the Nginx documentation, you should avoid using the if directive in Nginx where possible, because as soon as you have an if in your configuration your server needs to evaluate every single request to decide whether to match that if or not.
A better solution would be multiple server directives.
server {
... | NGINX | 1,629,231 | 40 |
Introduction
From NGINX version 1.9.11 and upwarts, a new feature is introduced: dynamic modules. With dynamic modules, you can optionally load separate shared object files at runtime as modules – both third-party modules and some native NGINX modules. (source)
My setup and the problem
I have NGINX installed from the m... | I had the same question, and @vladiastudillo answer was the missing piece I needed.
First add the nginx stable repo:
sudo add-apt-repository ppa:nginx/stable
Then run apt update:
sudo apt-get update
And get the nginx geoip module:
sudo apt-get install nginx-module-geoip
This will download and load the module to /usr... | NGINX | 36,554,405 | 39 |
After I changed ICG to nginx all routes except index page does not work.
Laravel Config:
#/etc/nginx/sites-enabled/laravel
server {
listen 80;
root /var/www/home;
index index.php;
server_name 192.168.178.71;
access_log /var/www/home/storage/app/logs/laravel-nginx-access.log;
error_log /var/w... | This is the correct basic config for Laravel and Nginx:
server {
listen 443 ssl default_server;
root /var/www/laravel/public/;
index index.php;
ssl_certificate /path/to/cert;
ssl_certificate_key /path/to/key;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass... | NGINX | 35,634,530 | 39 |
After i login and the cookie is set I get error 502. When i read the log i get the error:
014/05/17 01:54:43 [error] 11013#0: *8 upstream sent too big header while reading response
header from upstream, client: 83.248.134.236, server: , request: "GET /administration
HTTP/1.1", upstream:
After some fast googling i foun... | Amazon actually recommends editing the staging version of the nginx deployment file. There are several located at /tmp/deployment/config/, one for editing the general 'http' context, and then a few for configuring different aspects of the server.
I wanted to attach caching functionality to the default proxy server, so... | NGINX | 23,709,841 | 39 |
I'm setting up an Nginx server with an SSL.
The domain with the SSL is www.mydomain.example
I want to redirect all requests from:
http://mydomain.example, http://www.mydomain.example, & https://mydomain.example to
https://www.mydomain.example
I have the following server blocks setup currently:
server{
listen 443 ssl... | The SSL redirect won't work if your SSL certificate doesn't support the non-www domain.
The config is correct but can be reduced to just 1 redirect server
Also don't forget to reload Nginx sudo service nginx reload
server {
listen 80;
listen 443 ssl;
server_name example.com;
# add ssl settings
return 301 http... | NGINX | 21,106,998 | 39 |
nginx.conf:
server_tokens off;
Why could this get ignored, the header is still sent:
Server: nginx
No, other included config files do not contain server_tokens configuration.
Yes, I did restart all services.
| To cite the docs on the server_tokens directive:
Enables or disables emitting nginx version in error messages and in the “Server” response header field.
According to the docs, it thus doesn't prevent the generation of the Server header but only prevents the addition of the exact version. If you want to completely rem... | NGINX | 20,247,184 | 39 |
Can /etc/hosts be used instead of resolver when using proxy_pass?
I need to perform a proxy_pass to the same nginx machine. Is there a way to resolve the domains using the machine's /etc/hosts file instead of specifying a DNS server thru the "resolver" property?
This will save me the additional hops needed to reach the... | You can get around this by installing dnsmasq and setting your resolver to 127.0.0.1. Basically this uses your local DNS as a resolver, but it only resolves what it knows about (among those things is your /etc/hosts) and forwards the rest to your default DNS.
| NGINX | 8,305,015 | 39 |
I've tried so many different things. The point I'm at right now is this:
location ^~ /wordpress {
alias /var/www/example.com/wordpress;
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:900... | Since your location alias end match, you should just use root. Also, not everything is routed through index.php on wordpress afaik. Also, unless you know you need path info, you probably dont. I think you want something like:
location @wp {
rewrite ^/wordpress(.*) /wordpress/index.php?q=$1;
}
location ^~ /wordpre... | NGINX | 6,154,879 | 39 |
I'm just starting to explore nginx on my ubuntu 10.04. I installed nginx and I'm able to get the "Welcome to Nginx" page on localhost. However I'm not able to add a new server_name.
Even when I make the changes in site-available/default. I also tried reloading/restarting nginx, but nothing works.
| To build on mark's answer, Debian/Ubuntu distros default configuration file has an include /etc/nginx/sites-enabled/*; directive with site configuration file stored in /etc/nginx/sites-available/, a default site is usually included in that dir.
For examples beyond the default config, follow nginx beginner's guide or se... | NGINX | 4,891,344 | 39 |
I'm trying to understand what makes Nginx so fast, and I have a few questions.
As I understand it, Apache either spawns a new process to serve each request OR spawns a new thread to serve each request. Since each new thread shares virtual address space the memory usage keeps climbs if there are a number of concurrent r... | Apache uses multiple threads to provide each request with it's own thread of execution. This is necessary to avoid blocking when using synchronous I/O.
Nginx uses only asynchronous I/O, which makes blocking a non-issue. The only reason nginx uses multiple processes, is to make full use of multi-core, multi-CPU and hype... | NGINX | 4,764,731 | 39 |
I've set up Nginx as my main web server and have two Mochiweb based servers behind it. Certain requests are reverse-proxied to these two servers.
now, I want to access phpmyadmin (located at /var/www/nginx-default/phpMyAdmin) using nginx, but it keeps saying Error 404 not found. Am I missing something obvious here?
se... | The problem here is that only the "best" location directive gets taken, in this order:
location = <path> (longest match wins)
location ^~ <path> (longest match wins)
location ~ <path> (first defined match wins)
location <path> (longest match wins)
Using this ruleset, your /phpmyadmin location directive is bea... | NGINX | 1,011,101 | 39 |
I have the following API(s):
localhost:300/api/customers/
localhost:400/api/customers/:id/billing
localhost:500/api/orders
I'd like to use NGINX to have them all run under the following location:
localhost:443/api/
This seems very difficult because of customers spanning two servers.
Here's my failed attempt starting... | The three services are being proxied by the same server (as far as nginx is concerned) so must be structured as three location blocks within one server block. See this document for details.
If you are just passing the original URI unmodified, you do not need to specify a URI on the proxy_pass statement.
server {
{
... | NGINX | 39,769,963 | 38 |
are the following two nginx server blocks semantically the same, or is there any difference? Does the JSON-specific configuration in the first example inherit the settings of the "/" location? Does it in the second example?
server {
location / {
# ...
location ~* \.json$ {
# json-specific settings... | The inheritance of config directives in Nginx is such that directives can only be inherited from contexts higher up the configuration tree and never from contexts on the same level or lower.
So, a location block cannot inherit from another location block but a nested location block can inherit from the parent location ... | NGINX | 32,104,731 | 38 |
I'm trying to serve request to /blog subdirectory of a site with the php code, located in a folder outside document root directory. Here's my host config:
server {
server_name local.test.ru;
root /home/alex/www/test2;
location /blog {
alias /home/alex/www/test1;
try_files $uri $uri/ /i... | We could not get it to work by specifying root within the location block. The solution for us was to use alias instead. Note that it is necessary repeat the location's path twice in the try_files directive, and then also in the .php configuration block:
server {
server_name localhost;
root /app/frontend/www;
... | NGINX | 20,426,812 | 38 |
i am trying to configure nginx to proxy pass the request to another server,
only if the $request_body variable matches on a specific regular expression.
My problem now is, that I don't how to configure this behaviour exactly.
I am currently down to this one:
server {
listen 80 default;
server_name test.local... | try this:
server {
listen 80 default;
server_name test.local;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
if ($request_body ~* ^(.*)\.test) {
proxy_pass http://www.google.... | NGINX | 7,878,334 | 38 |
I have an issue wherein I am building an nginx reverse proxy for directing to multiple microservices at different url paths.
The system is entirely docker based and as a result the same environment is used for development and production. This has caused an issue for me when installing SSL as the SSL certs will only be ... | You can create an additional file ssl.conf and put here ssl configs:
ssl_certificate /etc/nginx/certs/atvcap_cabundle.crt;
ssl_certificate_key /etc/nginx/certs/atvcap.key;
Then include from the main config:
server_name atvcap.server.com;
include /somepath/ssl.conf*;
Make sure to include * symbol - thi... | NGINX | 47,575,376 | 37 |
I'm trying to learn how to use docker compose with a simple setup of an nginx container that reroutes requests to a ghost container. I'm using the standard ghost image but have a custom nginx image (that inherits from the standard image).
When I run the composition using "docker-compose up" it exits immediately with "... | The CMD in your Dockerfile should start a process which needs to run in foreground. The command service nginx start runs the process in deamon mode and thus your container exits cleanly because the service command exits.
Use the following CMD ["nginx", "-g", "daemon off;"] to start nginx (taken from official image) and... | NGINX | 33,724,125 | 37 |
UPDATE: See the answer I've provided below for the solution I eventually got set up on AWS.
I'm currently experimenting with methods to implement a global load-balancing layer for my app servers on Digital Ocean and there's a few pieces I've yet to put together.
The Goal
Offer highly-available service to my users by ... |
The Goal: Offer highly-available service to my users by routing all connections to the closest 'cluster' of servers in SFO, NYC, LON, and eventually Singapore.
The global-balancing layer then routes the request to theleast
connected server...
If I'm reading your configuration correctly, you're actually proxying from ... | NGINX | 25,678,049 | 37 |
I want to deploy a django site (it is the open source edx code on github).
I am faced with choosing between using
Apache with mod_wsgi
nginx with gunicorn
I have used Apache with mod_wsgi and it's cool enough, but i have no experience with the second option.
Which of these would be a better option in terms of speed a... | Nginx is a really light and easy to use solution and along with gunicorn it allows us to run any wsgi application and scale it easily.
Nginx is better at handling requests since it does not spawn a new process for every request unlike Apache.
I have written an answer on how to deploy django with nginx for a related que... | NGINX | 18,048,318 | 37 |
I am trying to enable gzip compression for components of my website. I use Ubuntu 11.04 server and Nginx 1.2.
In my Nginx configuration of the website, I have this:
gzip on;
#gzip_min_length 1000;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html tex... | As others have written, it's not enough to enable gzip compression in your server -- the client also needs to ask for it in its requests via the Accept-Encoding: gzip header (or a superset thereof). Modern browsers include this header automatically, but for curl you'll need to include one of the following in your comma... | NGINX | 15,999,606 | 37 |
Original: I have recently started getting MySQL OperationalErrors from some of my old code and cannot seem to trace back the problem. Since it was working before, I thought it may have been a software update that broke something. I am using python 2.7 with django runfcgi with nginx. Here is my original code:
views.py
D... | Sometimes if you see "OperationalError: (2006, 'MySQL server has gone away')", it is because you are issuing a query that is too large. This can happen, for instance, if you're storing your sessions in MySQL, and you're trying to put something really big in the session. To fix the problem, you need to increase the valu... | NGINX | 14,163,429 | 37 |
I'm migrating a website from a server that has Apache web-server to another server that is running Nginx web-server, and I wanted to convert the .htaccess files, the problem is not just the syntax but also the file name, is it also ".htaccess" or what?
| Here's a tool I use:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
It is not 100% accurate but it's pretty good base
Also, here's a link about converting the rules:
http://nginx.org/en/docs/http/converting_rewrite_rules.html
This one can help a little:
http://wiki.nginx.org/HttpRewriteModule#rewrite
EDIT:... | NGINX | 8,711,678 | 37 |
I have an nginx server and can't seem to find any information on how to send Vary: Accept-Encoding headers for CSS and JS files. Does anyone have info about this?
Thanks!
| This is from the nginx documentation.
gzip_vary
syntax: gzip_vary on|off
default: gzip_vary off
context: http, server, location
Enables response header of "Vary: Accept-Encoding". Note that this
header causes IE 4-6 not to cache the content due to a bug (see 2 ).
There if you just add gzip_vary on; it should do it... | NGINX | 6,637,678 | 37 |
I've created database, for example 'mydb'.
CREATE DATABASE mydb CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'myuser'@'%' IDENTIFIED BY PASSWORD '*HASH';
GRANT ALL ON mydb.* TO 'myuser'@'%';
GRANT ALL ON mydb TO 'myuser'@'%';
GRANT CREATE ON mydb TO 'myuser'@'%';
FLUSH PRIVILEGES;
Now i can login to database from... | GRANT ALL PRIVILEGES
ON mydb.*
TO 'myuser'@'%'
WITH GRANT OPTION;
This is how I create my "Super User" privileges (although I would normally specify a host).
IMPORTANT NOTE
While this answer can solve the problem of access, WITH GRANT OPTION creates a MySQL user that can edit the permissions of other users.
The GRANT... | MariaDB | 5,016,505 | 718 |
I'm importing a MySQL dump and getting the following error.
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
Apparently there are attachments in the database, which makes for very large inserts.
This is on my local machine, a Mac with MySQL 5 installed from the... | You probably have to change it for both the client (you are running to do the import) AND the daemon mysqld that is running and accepting the import.
For the client, you can specify it on the command line:
mysql --max_allowed_packet=100M -u root -p database < dump.sql
Also, change the my.cnf or my.ini file (usually fo... | MariaDB | 93,128 | 543 |
I am trying to optimize one part of my code that inserts data into MySQL. Should I chain INSERTs to make one huge multiple-row INSERT or are multiple separate INSERTs faster?
| https://dev.mysql.com/doc/refman/8.0/en/insert-optimization.html
The time required for inserting a row is determined by the following factors, where the numbers indicate approximate proportions:
Connecting: (3)
Sending query to server: (2)
Parsing query: (2)
Inserting row: (1 × size of row)
Inserting indexes: (1 × ... | MariaDB | 1,793,169 | 230 |
I have below query and need to cast id to varchar
Schema
create table t9 (id int, name varchar (55));
insert into t9( id, name)values(2, 'bob');
What I tried
select CAST(id as VARCHAR(50)) as col1 from t9;
select CONVERT(VARCHAR(50),id) as colI1 from t9;
but they don't work. Please suggest.
| You will need to cast or convert as a CHAR datatype, there is no varchar datatype that you can cast/convert data to:
select CAST(id as CHAR(50)) as col1
from t9;
select CONVERT(id, CHAR(50)) as colI1
from t9;
See the following SQL — in action — over at SQL Fiddle:
/*! Build Schema */
create table t9 (id INT, name V... | MariaDB | 15,368,753 | 161 |
I tried to use UTF-8 and ran into trouble.
I have tried so many things; here are the results I have gotten:
???? instead of Asian characters. Even for European text, I got Se?or for Señor.
Strange gibberish (Mojibake?) such as Señor or 新浪新闻 for 新浪新闻.
Black diamonds, such as Se�or.
Finally, I got into a situat... | This problem plagues the participants of this site, and many others.
You have listed the five main cases of CHARACTER SET troubles.
Best Practice
Going forward, it is best to use CHARACTER SET utf8mb4 and COLLATION utf8mb4_unicode_520_ci. (There is a newer version of the Unicode collation in the pipeline.)
utf8mb4 is a... | MariaDB | 38,363,566 | 114 |
Created a new database but can't create new user account due to this error.
Does anyone know how to fix this? I can't find any solution to fix this.
1030 - Got error 176 "Read page with wrong checksum" from storage engine Aria
| In my case above solution not worked. But the solution is similar to suggest by the @user13439511
Follow the below steps.
Select "mysql" database from the list of database.
Select all tables inside "mysql" database.
Scroll down and select "Repair Table" option in combobox.
Click on Go button.
Done.
| MariaDB | 60,864,367 | 109 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.