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 |
|---|---|---|---|---|
kubernetes seems to have lot of objects. I can't seem to find the full list of objects anywhere. After briefly searching on google, I can find results which mention a subset of kubernetes objects. Is the full list of objects documented somewhere, perhaps in source code? Thank you.
| Following command successfully display all kubernetes objects
kubectl api-resources
Example
[root@hsk-controller ~]# kubectl api-resources
NAME SHORTNAMES KIND
bindings Binding
componentstatuses cs ComponentStatu... | Kubernetes | 53,053,888 | 44 |
I daily find myself doing...
$ kubectl --context=foo get pods
< copy text manually >
$ kubectl --context=foo logs dep1-12345678-10101
I would like to cycle through matching resources with
$ kubectl --context=foo logs dep1<TAB>
but this doesn't seem to do anything with my stock setup. Any ideas?
osx 10.12.3
kubectl ... | Both bash and zsh supports scripts that completes printed command when you press <TAB>. The feature is called Programmable completion, and you can find more details about that here: zsh completion.
Fortunately, you don't need to write your own script - kubectl provides it for zsh > 5.2. Try running this command: source... | Kubernetes | 42,356,861 | 44 |
On my GCE Kubernetes cluster I can no longer create pods.
Warning FailedScheduling pod (www.caveconditions.com-f1be467e31c7b00bc983fbe5efdbb8eb-438ef) failed to fit in any node
fit failure on node (gke-prod-cluster-default-pool-b39c7f0c-c0ug): Insufficient CPU
Looking at the allocated stats of that node
Non-termina... | I recently had this same issue. After some research, I found that GKE has a default LimitRange with CPU requests limit set to 100m.
You can validate this by running kubectl get limitrange -o=yaml.
It's going to display something like this:
apiVersion: v1
items:
- apiVersion: v1
kind: LimitRange
metadata:
annota... | Kubernetes | 38,869,673 | 44 |
I have used kubectl create serviceaccount sa1 to create service account. Then I used kubectl get serviceaccount sa1 -oyaml command to get service account info. But it returns as below.
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: "2022-05-16T08:03:50Z"
name: sa1
namespace: default
resourceVe... | In Kubernetes 1.24, ServiceAccount token secrets are no longer automatically generated. See "Urgent Upgrade Notes" in the 1.24 changelog file:
The LegacyServiceAccountTokenNoAutoGeneration feature gate is beta, and enabled by default. When enabled, Secret API objects containing service account tokens are no longer au... | Kubernetes | 72,256,006 | 43 |
I'm running Docker Desktop for MacOS and I don't know how to stop the Docker service. It runs all the time using up the MacBook battery.
On a simple search, there are docs showing how to stop the containers but not the docker service itself.
I might be missing something obvious, but is there a way to stop both Kuberne... | The docker desktop app starts a qemu vm, so the desktop app has no control over the PIDs.
To overcome the "situation" do the following:
open the Terminal app
edit the file ~/.bash_profile
add the following lines
#macro to kill the docker desktop app and the VM (excluding vmnetd -> it's a service)
function... | Kubernetes | 64,799,841 | 43 |
I'm looking for a way to export a yaml file from a deployed component but without the cluster specific information.
kubectl get MYOBJECT --export -o yaml > my.yaml
but since "export" is now deprecated (since 1.14 and should normally disappear in 1.18 (didn't find it in changelog), what would be an alternative ?
thank... | Using JQ does the trick.
kubectl get secret <secretname> -ojson | jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid) | .metadata.creationTimestamp=null'
produces exactly the same JSON as
kubectl get secret <secretname> -ojson --export
| Kubernetes | 61,392,206 | 43 |
We are using one namespace for the develop environment and one for the staging environment. Inside each one of this namespaces we have several configMaps and secrets but there are a lot of share variables between the two environments so we will like to have a common file for those.
Is there a way to have a base configM... | Kubernetes 1.13 and earlier
They cannot be shared, because they cannot be accessed from a pods outside of its namespace. Names of resources need to be unique within a namespace, but not across namespaces.
Workaround it is to copy it over.
Copy secrets between namespaces
kubectl get secret <secret-name> --namespace=<sou... | Kubernetes | 55,515,594 | 43 |
how can I describe this command in yaml format?
kubectl create configmap somename --from-file=./conf/nginx.conf
I'd expect to do something like the following yaml, but it doesn't work
apiVersion: v1
kind: ConfigMap
metadata:
name: somename
namespace: default
fromfile: ./conf/nginx.conf
any idea?
| That won't work, because kubernetes isn't aware of the local file's path. You can simulate it by doing something like this:
kubectl create configmap --dry-run=client somename --from-file=./conf/nginx.conf --output yaml
The --dry-run flag will simply show your changes on stdout, and not make the changes on the server. ... | Kubernetes | 51,268,488 | 43 |
I understood Ingress can be used when we want to expose multiple service/routes with a single Load Balancer / public IP.
Now I want to expose my Nginx server to public. I have two choices
Set service type as LoadBalancer voila I got public IP
Use Nginx Ingress Controller
Now I can get my job done with Option 1 when o... | There is a difference between ingress rule (ingress) and ingress controller. So, technically, nginx ingress controller and LoadBalancer type service are not comparable. You can compare ingress resource and LoadBalancer type service, which is below.
Generally speaking:
LoadBalancer type service is a L4(TCP) load balance... | Kubernetes | 50,966,300 | 43 |
How the OR expression can be used with selectors and labels?
selector:
app: myapp
tier: frontend
The above matches pods where labels app==myapp AND tier=frontend.
But the OR expression can be used?
app==myapp OR tier=frontend?
| Now you can do that :
kubectl get pods -l 'environment in (production, qa)'
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering
| Kubernetes | 46,028,731 | 43 |
I followed the load balancer tutorial: https://cloud.google.com/container-engine/docs/tutorials/http-balancer which is working fine when I use the Nginx image, when I try and use my own application image though the backend switches to unhealthy.
My application redirects on / (returns a 302) but I added a livenessProb... | You need to add a readinessProbe (just copy your livenessProbe).
It's explained in the GCE L7 Ingress Docs.
Health checks
Currently, all service backends must satisfy either of the following requirements to pass the HTTP health checks sent to it from the GCE loadbalancer: 1. Respond with a 200 on '/'. The content does... | Kubernetes | 39,294,305 | 43 |
I'm new to Kubernetes. I try to scale my pods. First I started 3 pods:
./cluster/kubectl.sh run my-nginx --image=nginx --replicas=3 --port=80
There were starting 3 pods. First I tried to scale up/down by using a replicationcontroller but this did not exist. It seems to be a replicaSet now.
./cluster/kubectl.sh get rs
... | This is working for me
kubectl scale --replicas=<expected_replica_num> deployment <deployment_label_name> -n <namespace>
Example
# kubectl scale --replicas=3 deployment xyz -n my_namespace
| Kubernetes | 38,344,896 | 43 |
I have created a cluster of three nodes: one master, two minions.
How to check the cluster IP in Kubernetes?
Is it the IP of the master node?
| ClusterIP can mean 2 things: a type of service which is only accessible within a Kubernetes cluster, or the internal ("virtual") IP of components within a Kubernetes cluster. Assuming you're asking about finding the internal IP of a cluster, it can be accessed in 3 ways (using the simple-nginx example):
Via command li... | Kubernetes | 33,407,638 | 43 |
I have a configmap where I have defined the following key-value mapping in the data section:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: test
name: test-config
data:
TEST: "CONFIGMAP_VALUE"
then in the definition of my container (in the deployment / statefulset manifest) I have the following:
env... | From Kubernetes API reference:
envFrom : List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last s... | Kubernetes | 54,398,272 | 42 |
I'm trying to build a script that can follow(-f) kubectl get pods see a realtime update when I make any changes/delete pods on Ubuntu server.
What could be the easiest/efficient way to do so?
| You can just use
kubectl get pod <your pod name> -w
whenever any update/change/delete happen to the pod, you will see the update.
You can also use
watch -n 1 kubectl get pod <your pod name>
This will continuously run kubectl get pod ... with 1 seconds interval. So, you will see latest state.
| Kubernetes | 53,485,346 | 42 |
I don't really understand this after reading through the document. Some use a term like "CPU", but some use "core".
I am running Kubernetes in my laptop for testing purpose. My laptop has one CPU (2.2 GHz) and four cores.
If I want to set the CPU request/limit for pod, should the maximum resource that I have be 1000m o... | To clarify what's described here in the Kubernetes context, 1 CPU is the same as a core (Also more information here).
1000m (milicores) = 1 core = 1 vCPU = 1 AWS vCPU = 1 GCP Core.
100m (milicores) = 0.1 core = 0.1 vCPU = 0.1 AWS vCPU = 0.1 GCP Core.
For example, an Intel Core i7-6700 has four cores, but it has Hypert... | Kubernetes | 53,255,956 | 42 |
The docs states that
To create a Secret from one or more files, use --from-file. You
specify files in any plaintext format, such as .txt or .env, as long
as the files contain key-value pairs.
.test-secret
NAME=martin
GENDER=male
Testing to create a secret based on my .test-secret file.
kubectl create secret gen... | Yes, use the option --from-env-file
kubectl create secret generic person --from-env-file=.test-secret
To consume the secrets from the initial .env file in a pod, you can use the following :
apiVersion: v1
kind: Pod
metadata:
name: some-meta
spec:
containers:
- name: xyz
image: abc
envFrom:
- secretRe... | Kubernetes | 51,419,102 | 42 |
I am trying to run a Factorio game server on Kubernetes (hosted on GKE).
I have setup a Stateful Set with a Persistent Volume Claim and mounted it in the game server's save directory.
I would like to upload a save file from my local computer to this Persistent Volume Claim so I can access the save on the game server.... | It turns out there is a much simpler way: The kubectl cp command.
This command lets you copy data from your computer to a container running on your cluster.
In my case I ran:
kubectl cp ~/.factorio/saves/k8s-test.zip factorio/factorio-0:/factorio/saves/
This copied the k8s-test.zip file on my computer to /factorio... | Kubernetes | 50,703,727 | 42 |
In a kubernetes deployment I specify a port like so:
containers:
- name: nginx
image: nginx:latest
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
Now in a service I can reference that port like so (allows me to only specify the external port in the service):
spec:
type: ClusterIP
... | Usually, you refer to a target port by its number. But you can give a specific name to each pod`s port and refer to this name in your service specification.
This will make your service clearer. Here a small example:
apiVersion: v1
kind: Pod
metadata:
name: named-port-pod
labels:
app: named-port-pod
spec:
cont... | Kubernetes | 48,886,837 | 42 |
I can delete all jobs inside a custer running
kubectl delete jobs --all
However, jobs are deleted one after another which is pretty slow (for ~200 jobs I had the time to write this question and it was not even done).
Is there a faster approach ?
| It's a little easier to setup an alias for this bash command:
kubectl delete jobs `kubectl get jobs -o custom-columns=:.metadata.name`
| Kubernetes | 43,675,231 | 42 |
when running helm install (helm 3.0.2)
I got the following error: Error:
rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: kind: PodSecurityPolicy, namespace: , name: po-kube-state-metrics
But I don't find it and also In the error im not getting t... | First of all you need to make sure you've successfully uninstalled the helm release, before reinstalling.
To list all the releases, use:
$ helm list --all --all-namespaces
To uninstall a release, use:
$ helm uninstall <release-name> -n <namespace>
You can also use --no-hooks to skip running hooks for the command:
$ h... | Kubernetes | 59,443,834 | 41 |
I have a kubernetes setup with the configuration like below:
#---
kind: Service
apiVersion: v1
metadata:
name: myservice
spec:
selector:
app: my-service
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 8080
# Port to forward to inside the pod
targetPort: 80
---
a... | Your ingress targets this service:
serviceName: myservice
servicePort: 80
but the service named myservice exposes port 8080 rather than 80:
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 8080
# Port to forward to inside the pod
targetPort: 80
Your ingress shoul... | Kubernetes | 54,783,778 | 41 |
I have a Nginx running inside a docker container. I have a MySql running on the host system. I want to connect to the MySql from within my container. MySql is only binding to the localhost device.
Is there any way to connect to this MySql or any other program on localhost from within this docker container?
This questio... | Edit:
If you are using Docker-for-mac or Docker-for-Windows 18.03+, connect to your mysql service using the host host.docker.internal (instead of the 127.0.0.1 in your connection string).
If you are using Docker-for-Linux 20.10.0+, you can also use the host host.docker.internal if you started your Docker container with... | NGINX | 24,319,662 | 3,415 |
I've set up Node.js and Nginx on my server. Now I want to use it, but, before I start there are 2 questions:
How should they work together? How should I handle the requests?
There are 2 concepts for a Node.js server, which one is better:
a. Create a separate HTTP server for each website that needs it. Then load all... | Nginx works as a front end server, which in this case proxies the requests to a node.js server. Therefore you need to set up an Nginx config file for node.
This is what I have done in my Ubuntu box:
Create the file yourdomain.example at /etc/nginx/sites-available/:
vim /etc/nginx/sites-available/yourdomain.example
In ... | NGINX | 5,009,324 | 1,138 |
I need to serve my app through my app server at 8080, and my static files from a directory without touching the app server.
# app server on port 8080
# nginx listens on port 8123
server {
listen 8123;
access_log off;
location /static/ {
... | There is a very important difference between the root and the alias directives. This difference exists in the way the path specified in the root or the alias is processed.
root
the location part is appended to root part
final path = root + location
alias
the location part is replaced by the alias part
final path = a... | NGINX | 10,631,933 | 655 |
I am using nginx on Rackspace cloud following a tutorial and having searched the net and so far can't get this sorted.
I want www.mysite.example to go to mysite.example as normal in .htaccess for SEO and other reasons.
My /etc/nginx/sites-available/www.example.com.vhost config:
server {
listen 80;
server_... | HTTP Solution
From the documentation, "the right way is to define a separate server for example.org":
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
...
}
HTTPS Solution
For thos... | NGINX | 7,947,030 | 585 |
I'm using Django with FastCGI + nginx. Where are the logs (errors) stored in this case?
| Errors are stored in the nginx log file. You can specify it in the root of the nginx configuration file:
error_log /var/log/nginx/nginx_error.log warn;
On Mac OS X with Homebrew, the log file was found by default at the following location:
/usr/local/var/log/nginx
| NGINX | 1,706,111 | 458 |
I am working with configuring Django project with Nginx and Gunicorn.
While I am accessing my port gunicorn mysite.wsgi:application --bind=127.0.0.1:8001 in Nginx server, I am getting the following error in my error log file;
2014/05/30 11:59:42 [crit] 4075#0: *6 connect() to 127.0.0.1:8001 failed (13: Permission deni... | Disclaimer
Make sure there are no security implications for your use-case before running this.
Answer
I had a similar issue getting Fedora 20, Nginx, Node.js, and Ghost (blog) to work. It turns out my issue was due to SELinux.
This should solve the problem:
setsebool -P httpd_can_network_connect 1
Details
I checked fo... | NGINX | 23,948,527 | 416 |
All of a sudden I am getting the below nginx error
* Restarting nginx
* Stopping nginx nginx
...done.
* Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Addres... | I fixed this by running:
sudo apachectl stop
It turns out apache was running in the background and prevented nginx from starting on the desired port.
On Ubuntu, run:
sudo /etc/init.d/apache2 stop
| NGINX | 14,972,792 | 404 |
I have worked with Apache before, so I am aware that the default public web root is typically /var/www/.
I recently started working with nginx, but I can't seem to find the default public web root.
Where can I find the default public web root for nginx?
| If installing on Ubuntu using apt-get, try /usr/share/nginx/www.
EDIT:
On more recent versions the path has changed to:
/usr/share/nginx/html
2019 EDIT:
Might try in /var/www/html/index.nginx-debian.html too.
| NGINX | 10,674,867 | 403 |
I am getting these kind of errors:
2014/05/24 11:49:06 [error] 8376#0: *54031 upstream sent too big header while reading response header from upstream, client: 107.21.193.210, server: aamjanata.com, request: "GET /the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/aamjanata.com/the-brainwash-chronicle... | Add the following to your conf file
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
| NGINX | 23,844,761 | 348 |
What order do location directives fire in?
| From the HTTP core module docs:
Directives with the "=" prefix that match the query exactly. If found, searching stops.
All remaining directives with conventional strings. If this match used the "^~" prefix, searching stops.
Regular expressions, in the order they are defined in the configuration file.
If #3 yielded a ... | NGINX | 5,238,377 | 331 |
I update nginx to 1.4.7 and php to 5.5.12, After that I got the 502 error. Before I update everything works fine.
nginx-error.log
2014/05/03 13:27:41 [crit] 4202#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xx.xxx.xx.xx, server: localhost, request: ... | I had a similar error after php update. PHP fixed a security bug where o had rw permission to the socket file.
Open /etc/php5/fpm/pool.d/www.conf or /etc/php/7.0/fpm/pool.d/www.conf, depending on your version.
Uncomment all permission lines, like:
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
Re... | NGINX | 23,443,398 | 328 |
I am trying to deploy nginx on kubernetes, kubernetes version is v1.5.2,
I have deployed nginx with 3 replica, YAML file is below,
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: deployment-example
spec:
replicas: 3
revisionHistoryLimit: 2
template:
metadata:
labels:
app: nginx... | It looks like you are using a custom Kubernetes Cluster (using minikube, kubeadm or the like). In this case, there is no LoadBalancer integrated (unlike AWS or Google Cloud). With this default setup, you can only use NodePort or an Ingress Controller.
With the Ingress Controller you can setup a domain name which maps t... | NGINX | 44,110,876 | 323 |
I use nginx to as the front server, I have modified the CSS files, but nginx is still serving the old ones.
I have tried to restart nginx, to no success and I have Googled, but not found a valid way to clear it.
Some articles say we can just delete the cache directory: var/cache/nginx, but there is no such directory on... | I had the exact same problem - I was running my nginx in Virtualbox. I did not have caching turned on. But looks like sendfile was set to on in nginx.conf and that was causing the problem. @kolbyjack mentioned it above in the comments.
When I turned off sendfile - it worked fine.
This is because:
Sendfile is used to ‘... | NGINX | 6,236,078 | 317 |
I have 3 domain names and am trying to host all 3 sites on one server (a Digital Ocean droplet) using Nginx.
mysite1.name
mysite2.name
mysite3.name
Only 1 of them works. The other two result in 403 errors (in the same way).
In my nginx error log, I see: [error] 13108#0: *1 directory index of "/usr/share/nginx/mysite2.... | If you have directory indexing off, and is having this problem, it's probably because the try_files you are using has a directory option:
location / {
try_files $uri $uri/ /index.html index.php;
} ^ that is the issue
Remove it and it should work:
location / {
try_files $uri /index.html index.php;
}... | NGINX | 19,285,355 | 307 |
How can I have same rule for two locations in NGINX config?
I have tried the following
server {
location /first/location/ | /second/location/ {
..
..
}
}
but nginx reload threw this error:
nginx: [emerg] invalid number of arguments in "location" directive**
| Try
location ~ ^/(first/location|second/location)/ {
...
}
The ~ means to use a regular expression for the url. The ^ means to check from the first character. This will look for a / followed by either of the locations and then another /. Quoting from the docs,
A regular expression is preceded with the tilde (~) fo... | NGINX | 35,320,674 | 276 |
I installed Nginx on Centos 6 and I am trying to set up virtual hosts. The problem I am having is that I can't seem to find the /etc/nginx/sites-available directory.
Is there something I need to do in order to create it? I know Nginx is up and running because I can browse to it.
| Well, I think nginx by itself doesn't have that in its setup, because the Ubuntu-maintained package does it as a convention to imitate Debian's apache setup. You could create it yourself if you wanted to emulate the same setup.
Create /etc/nginx/sites-available and /etc/nginx/sites-enabled and then edit the http block... | NGINX | 17,413,526 | 255 |
Is there a way to have the master process log to STDOUT STDERR instead of to a file?
It seems that you can only pass a filepath to the access_log directive:
access_log /var/log/nginx/access.log
And the same goes for error_log:
error_log /var/log/nginx/error.log
I understand that this simply may not be a feature of ... | Edit: it seems nginx now supports error_log stderr; as mentioned in Anon's answer.
You can send the logs to /dev/stdout. In nginx.conf:
daemon off;
error_log /dev/stdout info;
http {
access_log /dev/stdout;
...
}
edit: May need to run ln -sf /proc/self/fd /dev/ if using running certain docker containers, then use... | NGINX | 22,541,333 | 241 |
In Nginx, what's the difference between variables $host and $http_host.
| $host is a variable of the Core module.
$host
This variable is equal to line Host in the header of request or
name of the server processing the request if the Host header is not
available.
This variable may have a different value from $http_host in such
cases: 1) when the Host input header is absent or has an empt... | NGINX | 15,414,810 | 235 |
I have nginx installed with PHP-FPM on a CentOS 5 box, but am struggling to get it to serve any of my files - whether PHP or not.
Nginx is running as www-data:www-data, and the default "Welcome to nginx on EPEL" site (owned by root:root with 644 permissions) loads fine.
The nginx configuration file has an include direc... | One permission requirement that is often overlooked is a user needs x permissions in every parent directory of a file to access that file. Check the permissions on /, /home, /home/demo, etc. for www-data x access. My guess is that /home is probably 770 and www-data can't chdir through it to get to any subdir. If it ... | NGINX | 6,795,350 | 230 |
I have reconfigured nginx but I can't get it to restart using the following configuration:
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/access.log;
error_log /var/log... | That is not an nginx configuration file. It is part of an nginx configuration file.
The nginx configuration file (usually called nginx.conf) will look like:
events {
...
}
http {
...
server {
...
}
}
The server block is enclosed within an http block.
Often the configuration is distributed acros... | NGINX | 41,766,195 | 228 |
I am transitioning my react app from webpack-dev-server to nginx.
When I go to the root url "localhost:8080/login" I simply get a 404 and in my nginx log I see that it is trying to get:
my-nginx-container | 2017/05/12 21:07:01 [error] 6#6: *11 open() "/wwwroot/login" failed (2: No such file or directory), client: 172.2... | The location block in your nginx config should be:
location / {
try_files $uri /index.html;
}
The problem is that requests to the index.html file work, but you're not currently telling nginx to forward other requests to the index.html file too.
| NGINX | 43,951,720 | 224 |
How can I redirect mydomain.example and any subdomain *.mydomain.example to www.adifferentdomain.example using Nginx?
| server_name supports suffix matches using .mydomain.example syntax:
server {
server_name .mydomain.example;
rewrite ^ http://www.adifferentdomain.example$request_uri? permanent;
}
or on any version 0.9.1 or higher:
server {
server_name .mydomain.example;
return 301 http://www.adifferentdomain.example$request_u... | NGINX | 6,045,020 | 221 |
I am installing a website in a droplet (Digital Ocean). I have an issue for install NGINX with PHP properly. I did a tutorial https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 but when I try to run some .php files it's just downloading it...
for example... ... | Try this:
Edit /etc/nginx/sites-available/default
Uncomment both listen lines to make Nginx listen on port 80 IPv4 and IPv6.
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
Leave server_name alone
# Make site accessible (...)
serv... | NGINX | 25,591,040 | 218 |
I'm so lost and new to building NGINX on my own but I want to be able to enable secure websockets without having an additional layer.
I don't want to enable SSL on the websocket server itself but instead I want to use NGINX to add an SSL layer to the whole thing.
Every web page out there says I can't do it, but I know... | Just to note that nginx has now support for Websockets on the release 1.3.13. Example of use:
location /websocket/ {
proxy_pass http://backend_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
You can also che... | NGINX | 12,102,110 | 217 |
I am running Django, FastCGI, and Nginx. I am creating an api of sorts that where someone can send some data via XML which I will process and then return some status codes for each node that was sent over.
The problem is that Nginx will throw a 504 Gateway Time-out if I take too long to process the XML -- I think long... | Proxy timeouts are well, for proxies, not for FastCGI...
The directives that affect FastCGI timeouts are client_header_timeout, client_body_timeout and send_timeout.
Edit: Considering what's found on nginx wiki, the send_timeout directive is responsible for setting general timeout of response (which was bit misleading)... | NGINX | 561,946 | 216 |
I have Nginx installed on a Docker container, and am trying to run it like this:
docker run -i -t -p 80:80 mydockerimage /usr/sbin/nginx
The problem is that the way Nginx works, is that the initial process immediately spawns a master Nginx process and some workers, and then quits. Since Docker is only watching the PID... | To expand on Charles Duffy's answer, Nginx uses the daemon off directive to run in the foreground. If it's inconvenient to put this in the configuration file, we can specify it directly on the command line. This makes it easy to run in debug mode (foreground) and directly switch to running in production mode (backgrou... | NGINX | 18,861,300 | 214 |
I am using the default config while adding the specific directory with nginx installed on my ubuntu 12.04 machine.
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
index index.html index.htm;
# Make s... | Nginx operates within the directory, so if you can't cd to that directory from the nginx user then it will fail (as does the stat command in your log). Make sure the www-user can cd all the way to the /username/test/static. You can confirm that the stat will fail or succeed by running
sudo -u www-data stat /username/te... | NGINX | 25,774,999 | 213 |
I have a webapp on a NGinx server. I set gzip on in the conf file and now I'm trying to see if it works. YSlow says it's not, but 5 out of 6 websites that do the test say it is. How can I get a definite answer on this and why is there a difference in the results?
| It looks like one possible answer is, unsurprisingly, curl:
$ curl http://example.com/ --silent --write-out "%{size_download}\n" --output /dev/null
31032
$ curl http://example.com/ --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null
2553
In the second case the client tells t... | NGINX | 9,140,178 | 210 |
I'm running into "413 Request Entity Too Large" errors when posting files larger than 10MB to our API running on AWS Elastic Beanstalk.
I've done quite a bit of research and believe that I need to up the client_max_body_size for Nginx, however I cannot seem to find any documentation on how to do this using Elastic Bean... | There are two methods you can take for this. Unfortunately some work for some EB application types and some work for others.
Supported/recommended in AWS documentation
For some application types, like Java SE, Go, Node.js, and maybe Ruby (it's not documented for Ruby, but all the other Nginx platforms seem to support ... | NGINX | 18,908,426 | 209 |
Working on a client's server where there are two different versions of nginx installed. I think one of them was installed with the brew package manager (its an osx box) and the other seems to have been compiled and installed with the nginx packaged Makefile. I searched for all of the nginx.conf files on the server, but... | Running nginx -t through your commandline will issue out a test and append the output with the filepath to the configuration file (with either an error or success message).
| NGINX | 19,910,042 | 204 |
I'm in the process of setting up a new server. The web server of my choice is NGINX. I want to add the domain (e.g. example.com) as a virtual host. I already have two other domains in there and it works fine, but when I try to add the above mentioned domain and start the server it gives me:
Job failed. See system jour... | This is most likely happening because of the long domain name. You can fix this by adding
server_names_hash_bucket_size 64;
at the top of your http block (probably located in /etc/nginx/nginx.conf). I quote from the nginx documentation what to do when this error appears:
In this case, the directive value should be i... | NGINX | 13,895,933 | 204 |
I want to increase the maximum file size that can be uploaded.
After doing some research online, I found that you have to edit the file 'nginx.conf'.
The only way I can currently access this file is by going through Putty and typing in the command:
vi /etc/nginx/nginx.conf
This will open the file but I have 2 question... | Add client_max_body_size
Now that you are editing the file you need to add the line into the server block, like so;
server {
client_max_body_size 8M;
//other lines...
}
If you are hosting multiple sites add it to the http context like so;
http {
client_max_body_size 8M;
//other lines...
}
And also u... | NGINX | 26,717,013 | 202 |
Using nginx, I want to preserve the url, but actually load the same page no matter what. I will use the url with History.getState() to route the requests in my javascript app. It seems like it should be a simple thing to do?
location / {
rewrite (.*) base.html break;
}
works, but redirects the url? I still need... | I think this will do it for you:
location / {
try_files /base.html =404;
}
| NGINX | 7,027,636 | 192 |
I'm not able to setup SSL. I've Googled and I found a few solutions but none of them worked for me. I need some help please...
Here's the error I get when I attempt to restart nginx:
root@s17925268:~# service nginx restart
Restarting nginx: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/conf.d/ssl/ssl.key") fai... | Once you have established that they don't match, you still have a problem -- what to do about it. Often, the certificate may merely be assembled incorrectly. When a CA signs your certificate, they send you a block that looks something like
-----BEGIN CERTIFICATE-----
MIIAA-and-a-buncha-nonsense-that-is-your-certificat... | NGINX | 26,191,463 | 187 |
upstream apache {
server 127.0.0.1:8080;
}
server{
location ~* ^/service/(.*)$ {
proxy_pass http://apache/$1;
proxy_redirect off;
}
}
The above snippet will redirect requests where the url includes the string "service" to another server, but it does not include query parameters.
| From the proxy_pass documentation:
A special case is using variables in the proxy_pass statement: The requested URL is not used and you are fully responsible to construct the target URL yourself.
Since you're using $1 in the target, nginx relies on you to tell it exactly what to pass. You can fix this in two ways. ... | NGINX | 8,130,692 | 187 |
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
#root /usr/share/nginx/www;
root /home/ubuntu/node-login;
# Make site accessible from
server_name ec2-xx-xx-xxx-xxx.us-west-1.compute.amazonaws.com;
location /{
... | I assume that you're running a Linux, and you're using gEdit to edit your files. In the /etc/nginx/sites-enabled, it may have left a temp file e.g. default~ (watch the ~).
Depending on your editor, the file could be named .save or something like it. Just run $ ls -lah to see which files are unintended to be there and ... | NGINX | 11,426,087 | 185 |
I have been getting the nginx error:
413 Request Entity Too Large
I have been able to update my client_max_body_size in the server section of my nginx.conf file to 20M and this has fixed the issue. However, what is the default nginx client_max_body_size?
| The default value for client_max_body_size directive is 1 MiB.
It can be set in http, server and location context — as in the most cases,
this directive in a nested block takes precedence over the same directive in the ancestors blocks.
Excerpt from the ngx_http_core_module documentation:
Syntax: client_max_body_si... | NGINX | 28,476,643 | 184 |
I have setup an nginx server with php5-fpm. When I try to load the site I get a blank page with no errors. Html pages are served fine but not php. I tried turning on display_errors in php.ini but no luck. php5-fpm.log is not producing any errors and neither is nginx.
nginx.conf
server {
listen 80;
root /ho... | replace
include fastcgi_params;
with
include fastcgi.conf;
and remove fastcgi_param SCRIPT_FILENAME ... in nginx.conf
| NGINX | 15,423,500 | 183 |
I have an instance of nginx running which serves several websites. The first is a status message on the server's IP address. The second is an admin console on admin.domain.com. These work great. Now I'd like all other domain requests to go to a single index.php - I have loads of domains and subdomains and it's impracti... | Change listen option to this in your catch-all server block. (Add default_server) this will take all your non-defined connections (on the specified port).
listen 80 default_server;
if you want to push everything to index.php if the file or folder does not exist;
try_files $uri /$uri /index... | NGINX | 9,454,764 | 179 |
In order to deal with the microservice architecture, it's often used alongside a Reverse Proxy (such as nginx or apache httpd) and for cross cutting concerns implementation API gateway pattern is used. Sometimes Reverse proxy does the work of API gateway.
It will be good to see clear differences between these two appr... | It is easier to think about them if you realize they aren't mutually exclusive. Think of an API gateway as a specific type reverse proxy implementation.
In regards to your questions, it is not uncommon to see both used in conjunction where the API gateway is treated as an application tier that sits behind a reverse pro... | NGINX | 35,756,663 | 173 |
I have nginx up and running with a Ruby/Sinatra app and all is well. However, I'm now trying to have a second application running from the same server and I noticed something weird. First, here's my nginx.conf:
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
... | The first server block in the nginx config is the default for all requests that hit the server for which there is no specific server block.
So in your config, assuming your real domain is REAL.COM, when a user types that in, it will resolve to your server, and since there is no server block for this setup, the server b... | NGINX | 9,824,328 | 169 |
There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header?
| If you are using nginx to proxy a back-end application and want the back-end to advertise its own Server: header without nginx overwriting it, then you can go inside of your server {…} stanza and set:
proxy_pass_header Server;
That will convince nginx to leave that header alone and not rewrite the value set by the bac... | NGINX | 246,227 | 169 |
I have a docker with version 17.06.0-ce. When I trying to install NGINX using docker with command:
docker run -p 80:80 -p 8080:8080 --name nginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx:latest
It shows that
docker: Error response from daemon: oci runtime error:
c... | This should no longer happen (since v2.2.0.0), see here
If you are using Docker for Windows, this error can happen if you have recently changed your password.
How to fix:
First make sure to delete the broken container's volume
docker rm -v <container_name>
Update: The steps below may work without needing to delete vo... | NGINX | 45,972,812 | 167 |
I need to redirect every http://test.com request to http://www.test.com. How can this be done.
In the server block I tried adding
rewrite ^/(.*) http://www.test.com/$1 permanent;
but in browser it says
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address... | Best way to do what you want is to add another server block:
server {
#implemented by default, change if you need different ip or port
#listen *:80 | *:8000;
server_name test.com;
return 301 $scheme://www.test.com$request_uri;
}
And edit your main server block server_name variable as fo... | NGINX | 10,294,481 | 157 |
I have recently started migrating to Docker 1.9 and Docker-Compose 1.5's networking features to replace using links.
So far with links there were no problems with nginx connecting to my php5-fpm fastcgi server located in a different server in one group via docker-compose. Newly though when I run docker-compose --x-netw... | This can be solved with the mentioned depends_on directive since it's implemented now (2016):
version: '2'
services:
nginx:
image: nginx
ports:
- "42080:80"
volumes:
- ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- php
php:
... | NGINX | 33,639,138 | 156 |
I have this in Nginx configuration files
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
but Nginx give error when starting up
[warn]: duplicate MIME type "text/html" in /etc/nginx/nginx.conf:25
What is actually duplicate... | For the option gzip_types, the mime-type text/html is always included by default, so you don't need to specify it explicitly.
| NGINX | 6,475,472 | 156 |
After NGINX upgrade to v1.15.2 starts getting the warning.
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/etc/nginx/sites-enabled/confid-file-name:8
Where the 8th line is ssl on;
how I can solve this?
| Edit your listen statement from:
listen 443;
to
listen 443 ssl;
and comment out or delete :
# ssl on;
then check nginx -t again.
| NGINX | 51,703,109 | 155 |
I've always thought of upstream and downstream along the lines of an actual stream, where the flow of information is like water. So upstream is where water/data comes from (e.g. an HTTP request) and downstream is where it goes (e.g. the underlying system that services the request).
I've been looking at API gateways rec... | In HTTP world, the "upstream server" term was introduced in the HTTP/1.0 specification, RFC 1945:
502 Bad Gateway
The server, while acting as a gateway or proxy, received an invalid
response from the upstream server it accessed in attempting to
fulfill the request.
Formal definition was added later, in RFC 2616:
ups... | NGINX | 32,364,579 | 150 |
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?
| You likely have other files (such as the default configuration) located in /etc/nginx/sites-enabled that needs to be removed.
This issue is caused by a repeat of the default_server parameter supplied to one or more listen directives in your files. You'll likely find this conflicting directive reads something similar t... | NGINX | 30,973,774 | 150 |
I'm running a Sinatra app behind passenger/nginx. I'm trying to get it to respond to both http and https calls. The problem is, when both are defined in the server block https calls are responded to normally but http yields a 400 "The plain HTTP request was sent to HTTPS port" error. This is for a static page so I'm gu... | I ran into a similar problem. It works on one server and does not on another server with same Nginx configuration. Found the the solution which is answered by Igor here http://forum.nginx.org/read.php?2,1612,1627#msg-1627
Yes. Or you may combine SSL/non-SSL servers in one server:
server {
listen 80;
listen 443 de... | NGINX | 8,768,946 | 150 |
I am trying to link 2 separate containers:
nginx:latest
php:fpm
The problem is that php scripts do not work. Perhaps the php-fpm configuration is incorrect.
Here is the source code, which is in my repository. Here is the file docker-compose.yml:
nginx:
build: .
ports:
- "80:80"
- "443:443"
... | I know it is kind an old post, but I've had the same problem and couldn't understand why your code didn't work.
After a LOT of tests I've found out why.
It seems like fpm receives the full path from nginx and tries to find the files in the fpm container, so it must be the exactly the same as server.root in the nginx c... | NGINX | 29,905,953 | 148 |
I would like to know the difference between Nginx and Unicorn. As far as I understand, Nginx is a web server while Unicorn is a Ruby HTTP server.
Since both Nginx and Unicorn can handle HTTP requests, what is the need to use the combination of Nginx and Unicorn for RoR applications?
| Nginx is a pure web server that's intended for serving up static content and/or redirecting the request to another socket to handle the request.
Unicorn is a Rack web server and only intended to host a 'Rack App' which is usually generating dynamic content. Rack apps can also serve up static content but it's less effi... | NGINX | 8,739,871 | 147 |
I would like to host 2 different domains in the same server using Nginx.
I redirected both domains to this host via @ property. Although I configure 2 different server blocks, whenever I try to access second domain, it redirects to first one.
Here is my config.
server {
listen `www.domain1.example:80`;
acc... | Your "listen" directives are wrong. See this page: http://nginx.org/en/docs/http/server_names.html.
They should be
server {
listen 80;
server_name www.domain1.example;
root /var/www/domain1;
}
server {
listen 80;
server_name www.domain2.example;
root /var/www/domain2;
}
Note, I have... | NGINX | 11,773,544 | 145 |
I'm looking at the WSGI specification and I'm trying to figure out how servers like uWSGI fit into the picture. I understand the point of the WSGI spec is to separate web servers like nginx from web applications like something you'd write using Flask. What I don't understand is what uWSGI is for. Why can't nginx direct... | Okay, I think I get this now.
Why can't nginx directly call my Flask application?
Because nginx doesn't support the WSGI spec. Technically nginx could implement the WSGI spec if they wanted, they just haven't.
That being the case, we need a web server that does implement the spec, which is what the uWSGI server is fo... | NGINX | 38,601,440 | 143 |
I have been studying Node.js recently and came across some material on writing simple Node.js based servers. For example, the following.
var express = require("express"),
http = require("http"), app;
// Create our Express-powered HTTP server
// and have it listen on port 3000
app = express();
http.createServer(app).li... | It's a server, yes.
A node.js web application is a full-fledged web server just like Nginx or Apache.
You can indeed serve your node.js application without using any other web server. Just change your code to:
app = express();
http.createServer(app).listen(80); // serve HTTP directly
Indeed, some projects use node.js ... | NGINX | 38,821,947 | 142 |
I am using nginx and node server to serve update requests. I get a gateway timeout when I request an update on large data. I saw this error from the nginx error logs :
2016/04/07 00:46:04 [error] 28599#0: *1 upstream prematurely closed
connection while reading response header from upstream, client:
10.0.2.77, server: ... | I solved this by setting a higher timeout value for the proxy:
location / {
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_pass http://localhost:3000;
}
Documentation: https://nginx.org/en/docs/http/ngx_http_proxy_module.html
| NGINX | 36,488,688 | 142 |
When I restart the nginx service on a command line on an Ubuntu server, the service crashes when a nginx configuration file has errors. On a multi-site server this puts down all the sites, even the ones without configuration errors.
To prevent this, I run the nginx configuration test first:
nginx -t
After the test ran... | As of nginx 1.8.0, the correct solution is
sudo nginx -t && sudo service nginx reload
Note that due to a bug, configtest always returns a zero exit code even if the config file has an error.
| NGINX | 18,587,638 | 139 |
I want to add a custom header for the response received from the server behind nginx.
While add_header works for nginx-processed responses, it does nothing when the proxy_pass is used.
| add_header works as well with proxy_pass as without. I just today set up a configuration where I've used exactly that directive. I have to admit though that I've struggled as well setting this up without exactly recalling the reason, though.
Right now I have a working configuration and it contains the following (among ... | NGINX | 14,501,047 | 138 |
After running an ASP.NET vNext project on my local machine I was trying to figure out how I can run it on nginx as it looks to be a recommended choice
Following jsinh's blog, I installed it using:
sudo apt-get update
sudo apt-get install nginx -y
I was trying to understand whether it is working or not by using:
ifcon... | Looking at the requirement you have, the below command shall help:
service nginx status
| NGINX | 35,220,654 | 132 |
I am running a command
./startup.sh nginx:start
and I am getting this error message
zsh: permission denied: ./startup.sh
why could this be happening?
| Be sure to give it the execution permission.
cd ~/the/script/folder
chmod +x ./startup.sh
This will give exec permission to user, group and other, so beware of possible security issues. To restrict permission to a single access class, you can use:
chmod u+x ./startup.sh
This will grant exec permission only to user
F... | NGINX | 53,229,221 | 131 |
I'm in the process of reorganizing URL structure.
I need to setup redirect rules for specific URLs - I'm using Nginx.
Basically Something like this:
http://example.com/issue1 --> http://example.com/shop/issues/custom_issue_name1
http://example.com/issue2 --> http://example.com/shop/issues/custom_issue_name2
http://exam... | location ~ /issue([0-9]+) {
return 301 http://example.com/shop/issues/custom_isse_name$1;
}
| NGINX | 18,037,716 | 126 |
I've recently decided to switch from Apache2 to Nginx. I installed Nginx on my CentOS server and setup a basic configuration.
When I tried to load my site in browser (FF/Chrome) I noticed that css file is not loaded. I checked the error console and saw this message:
Error: The stylesheet http://example.com/style.css wa... | Putting the include /etc/nginx/mime.types; under location / { instead of under http { solved the issue for me.
| NGINX | 10,075,304 | 125 |
I'm used to using Apache with mod_proxy_html, and am trying to achieve something similar with NGINX. The specific use case is that I have an admin UI running in Tomcat on port 8080 on a server at the root context:
http://localhost:8080/
I need to surface this on port 80, but I have other contexts on the NGINX server ... | We should first read the documentation on proxy_pass carefully and fully.
The URI passed to upstream server is determined based on whether "proxy_pass" directive is used with URI or not. Trailing slash in proxy_pass directive means that URI is present and equal to /. Absense of trailing slash means hat URI is absent.
P... | NGINX | 32,542,282 | 124 |
I want to redirect all the HTTP request to https request on ELB. I have two EC2 instances. I am using nginx for the server. I have tried a rewriting the nginx conf files without any success. I would love some advice on it.
| AWS Application Load Balancers now support native HTTP to HTTPS redirect.
To enable this in the console, do the the following:
Go to your Load Balancer in EC2 and tab "Listeners"
Select "View/edit rules" on your HTTP listener
Delete all rules except for the default one (bottom)
Edit default rule: choose "Redirect to" ... | NGINX | 24,603,620 | 124 |
Once I've seen this before when I type a URL http://test.com/test/, instead of give me a html page, it gives me a 'file browser' like interface to browse all the files in the given location.
I think it maybe a nginx module that could be enable in the location context.
The nginx.conf file:
worker_processes 1;
events {
... | You should try ngx_http_autoindex_module.
Set autoindex option to on. It is off by default.
Your example configuration should be ok
location /{
root /home/yozloy/html/;
index index.html;
autoindex on;
}
Without autoindex option you should be getting Error 403 for requests that end with / on directories tha... | NGINX | 10,663,248 | 124 |
On server-side using Sinatra with a stream block.
get '/stream', :provides => 'text/event-stream' do
stream :keep_open do |out|
connections << out
out.callback { connections.delete(out) }
end
end
On client side:
var es = new EventSource('/stream');
es.onmessage = function(e) { $('#chat').append(e.data + "\... | Your Nginx config is correct, you just miss few lines.
Here is a "magic trio" making EventSource working through Nginx:
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
Place them into location section and it should work.
You may also need to add
proxy_buffering off;
proxy_cache o... | NGINX | 13,672,743 | 123 |
I'm running nginx/ruby-on-rails and I have a simple multipart form to upload files.
Everything works fine until I decide to restrict the maximum size of files I want uploaded.
To do that, I set the nginx client_max_body_size to 1m (1MB) and expect a HTTP 413 (Request Entity Too Large) status in response when that rule... | nginx "fails fast" when the client informs it that it's going to send a body larger than the client_max_body_size by sending a 413 response and closing the connection.
Most clients don't read responses until the entire request body is sent. Because nginx closes the connection, the client sends data to the closed socke... | NGINX | 4,947,107 | 122 |
I'm an nginx noob trying out this this tutorial on nginx 1.1.19 on ubuntu 12.04. I have this nginx config file.
When I run this command the test fails:
$ sudo service nginx restart
Restarting nginx: nginx: [crit] pread() "/etc/nginx/sites-enabled/csv" failed (21: Is a directory)
nginx: configuration file /etc/nginx/ngi... | sudo nginx -t should test all files and return errors and warnings locations
| NGINX | 22,306,006 | 120 |
We have a server that is serving one html file.
Right now the server has 2 CPUs and 2GB of ram. From blitz.io, we are getting about 12k connections per minute and anywhere from 200 timeouts in that 60 seconds with 250 concurrent connections each second.
worker_processes 2;
events {
worker_connections 1024;
}
If I ... | Config file:
worker_processes 4; # 2 * Number of CPUs
events {
worker_connections 19000; # It's the key to high performance - have a lot of connections available
}
worker_rlimit_nofile 20000; # Each connection needs a filehandle (or 2 if you are proxying)
# Total amount of users you can serve = worker_p... | NGINX | 7,325,211 | 119 |
I am using nginx as a reverse proxy and trying to read a custom header from the response of an upstream server (Apache) without success. The Apache response is the following:
HTTP/1.0 200 OK
Date: Fri, 14 Sep 2012 20:18:29 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.10
Connection: close
Content... | It's not only possible, it's easy:
in nginx the response header values are available through a variable (one per header).
See http://wiki.nginx.org/HttpCoreModule#.24sent_http_HEADER for the details on those variables.
In your examle the variable would be $sent_http_My_custom_header.
| NGINX | 12,431,496 | 115 |
I was trying to use Thin app server and had one issue.
When nginx proxies the request to Thin (or Unicorn) using proxy_pass http://my_app_upstream; the application receives the modified URL sent by nginx (http://my_app_upstream).
What I want is to pass the original URL and the original request from client with no modi... | I think the proxy_set_header directive could help:
location / {
proxy_pass http://my_app_upstream;
proxy_set_header Host $host;
# ...
}
| NGINX | 5,834,025 | 114 |
We have an Angular 6 application. It’s served on Nginx. And SSL is on.
When we deploy new codes, most of new features work fine but not for some changes. For example, if the front-end developers update the service connection and deploy it, users have to open incognito window or clear cache to see the new feature.
What ... | The problem is When a static file gets cached it can be stored for very long periods of time before it ends up expiring. This can be an annoyance in the event that you make an update to a site, however, since the cached version of the file is stored in your visitors’ browsers, they may be unable to see the changes made... | NGINX | 55,402,751 | 113 |
Is it possible to get which conf the nginx is using only from a running nginx process?
To get the conf file path. sometimes ps aux reveal it, sometimes it doesn't. It might be just something like nginx: master process /usr/sbin/nginx (same as /proc/PID/cmdline)
So is nginx -V the only solution?
From this question, is ... | As of Nginx 1.9.2 you can dump the Nginx config with the -T flag:
-T — same as -t, but additionally dump configuration files to standard output (1.9.2).
Source: http://nginx.org/en/docs/switches.html
This is not the same as dumping for a specific process. If your Nginx is using a different config file, check the outp... | NGINX | 12,832,033 | 113 |
Just want to help somebody out. yes ,you just want to serve static file using nginx, and you got everything right in nginx.conf:
location /static {
autoindex on;
#root /root/downloads/boxes/;
alias /root/downloads/boxes/;
}
But , in the end , you failed. You got "403 forbidden" from browser.... | You should give nginx permissions to read the file. That means you should give the user that runs the nginx process permissions to read the file.
This user that runs the nginx process is configurable with the user directive in the nginx config, usually located somewhere on the top of nginx.conf:
user www-data
http://w... | NGINX | 16,808,813 | 112 |
I had a problem with a custom HTTP SESSION_ID header not being transfered by nginx proxy.
I was told that underscores are prohibited according to the HTTP RFC.
Searching, I found that most servers like Apache or nginx define them as illegal in RFC2616 section 4.2, which says:
follow the same generic format as that giv... | They are not forbidden, it's CGI legacy. See "Missing (disappearing) HTTP Headers".
If you do not explicitly set underscores_in_headers on;, nginx will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping heade... | NGINX | 22,856,136 | 111 |
I am writing an express app that sits behind an nginx server. I was reading through express's documentation and it mentioned the 'trust proxy' setting. All it says is
trust proxy Enables reverse proxy support, disabled by default
I read the little article here that explains Secure Sessions in Node with nginx.
http:... | This is explained in detail in the express behind the proxies guide
By enabling the "trust proxy" setting via app.enable('trust proxy'), Express will have knowledge that it's sitting behind a proxy and that the X-Forwarded-* header fields may be trusted, which otherwise may be easily spoofed.
Enabling this setting has... | NGINX | 23,413,401 | 110 |
I have a problem with my MySQL error log which currently mostly consists of "mbind: Operation not permitted" lines (see below). Why does it happen and how do I fix it?
It's the "mostly" part that bothers me. As you can see below, not all lines are "mbind: Operation not permitted". I suspect that MySQL query errors shou... | Add the capability CAP_SYS_NICE to your container until MySQL server can handle the error itself "silently".
service:
mysql:
image: mysql:8.0.15
# ...
cap_add:
- SYS_NICE # CAP_SYS_NICE
If you don't have docker-compose, then you can define CAP_SYS_NICE via
docker run --cap-add=sys_nice -d mysql
R... | NGINX | 55,559,386 | 108 |
I am trying to get rid of deprecated Docker links in my configuration. What's left is getting rid of those Bad Gateway nginx reverse proxy errors when I recreated a container.
Note: I am using Docker networks in bridge mode. (docker network create nettest)
I am using the following configuration snippet inside nginx:
lo... | First off, you should be using the Docker embedded DNS server at 127.0.0.11.
Your problem could be caused by 1 of the following:
nginx is trying to use IPv6 (AAAA record) for the DNS queries.
See https://stackoverflow.com/a/35516395/1529493 for the solution.
Basically something like:
http {
resolver 127.0.0.11 ipv... | NGINX | 35,744,650 | 107 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.