Install Nginx on Mac local with brew install nginx. I don’t know why nginx local does not have the conf.d folder and the contents in it. (If you use docker run, there will be /etc/nginx/conf.d/default.conf
But in Mac local I don’t know why there is no
The main configuration in nginx docker access_log /var/log/nginx/access.log main in nginx.conf; is open, open access.log but there is nothing there, while local nginx has something as soon as it is opened (and The access_log /var/log/nginx/access.log in local nginx.conf is actually a comment by default)
Later, I found that there is a line in default.conf in nginx docker #access_log /var/log/nginx/host.access.log main; Is this to be turned on?
And in nginx docker, nginx.conf has access_log /var/log/nginx/access.log main; but there is still no log. When will this line be used?
i think the location for the nginx configuration file on mac is different.
try to check in
/usr/local/etc/nginx/
Related
I am using nginx on my ubuntu machine and setup 2 laravel application using docker and one wordpress website without docker
Application 1: localhost:8088
Application 2: localhost:8089
I wanted to achieve is that when someone open localhost so it opens wordpress website and if someone open localhost/app1 it opens application 1 and so on.
So I have created reverse proxy so that it can open my docker container application
This is what I have done
sudo nano /etc/nginx/sites-available/website
ln -s /etc/nginx/sites-available/website /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx
After doing so when I try to open localhost/app1 it shows 404 but it recognise its a laravel app but shows 404
Here is my /etc/nginx/sites-available/website file code
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1/{
proxy_pass http://localhost:8088;
}
}
You can create a file named redirects.map inside the nginx folder of your application and add a mapping like
~^localhost/app1/(.*) localhost:8089/$1;
You should change nginx configure from
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1/{
proxy_pass http://localhost:8088;
}
}
To
server{
listen 80;
server_name localhost;
root /var/www/html/wordpress;
location /app1 {
proxy_pass http://localhost:8088;
}
}
I Have installed Nginx-full via homebrew to the latests stable 1.8.1 version. I have installed php7.0 via brew as well. I want to get php working but i can't first get nginx to serve a static file. I have this configuration on a server and works perfectly but on my mac I'm having trouble. I set up my sites directory as follows:
nginx.conf:
#user www-data www-data;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/sites-available/default
server {
listen 80;
server_name localhost;
root /Users/londreblocker/Developer/Sites/bootstrap;
index index.php
error_log /Users/londreblocker/Logs/DMFA_erros.log;
access_log
/Users/londreblocker/Logs/DMFA_access.log;
}
there is a symbolic link to default in the sites-enabled folder. When i try to connect all i get is
This webpage is not available
ERR_CONNECTION_REFUSED
Any idea what could be going wrong. I am on a mac with El Capitan.
Check if nginx configuration is correct:
sudo nginx -t
and your config symlinks not broken:
ls -al /etc/nginx/sites-enabled
Check if nginx running:
ps aux |grep nginx
Check if nginx listening port 80:
sudo lsof -i -P | grep -i "listen"
If anyone is interested in my solution.
I had more than one version of nginx running due to previous install attempts and incorrect uninstalls. I deleted all versions and then did a reinstall. Seems to be working now.
I've set up a new macbook pro with El Capitan, I used homebrew to install everything. Also using brew services to start and stop launchctl.
I'm not sure what the problem is, I have it working on my iMac and did the same thing on the MBP, the config file is untouched, so I should be getting the default welcome screen on localhost, server_name is set to localhost
Any suggestions?
So the fix was adding [::]:8080 to the nginx.conf file
I used sudo lsof -i TCP -Pn | grep nginx and saw it
was listening for ipv6 like #ZYWJ was hinting at.
So your nginx.conf file should look something like this:
server {
listen [::]:8080;
server_name localhost;
}
I installed with homebrew
I hope this helps anyone with the same problem.
I use the official nginx docker image (https://registry.hub.docker.com/_/nginx/). When I modify the Index.html I don't see my change. Setting sendfile off in nginx.conf didn't help.
I only see the change if i rebuild my image.
Here is my Dockerfile:
FROM nginx
COPY . /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
And that's the commands I use to build and run it:
docker build -t some-nginx .
docker run --name app1 -p 80:80 -v $(pwd):/user/share/nginx/html -d some-nginx
Thank you
It's not caching. Once a file is copied into a container image (using the COPY instruction), modifying it from the host will have no effect - it's a different file.
You've attempted to overwrite the file by bind-mounting a volume from the host using the -v argument to docker run. This will work - you will now be using the same file on host and container, except you made a typo - it should be /usr not /user.
Just modify sendfile off in nginx.conf file can be work.
I'm running Laravel/Homestead as my Vagrant box and have heard that Nginx has some weird caching issues. The way to solve the problem is to set "sendfille off" in the nginx config file.
How can I provision my Laravel/Homestead Vagrant box so that I don't have to ssh into the box and modify the setting?
In your host's homestead folder you can find homestead/scripts/serve.sh. There sendfile is already set to off as default for your app. I think this will set nginx sendfile option to off.
If you still want to edit the nginx.conf permanently, write a line of code into serve.sh to change the config file.
More info on serve.sh
The serve.sh script will run on --provision for any site configured in the Homestead.yaml.
It creates each site in /etc/nginx/sites-available/ and symlinks it to /etc/nginx/sites-enabled/. Nginx and php5-fpm get restarted after that.
In nginx.conf we can see at the end of the http{...}-block has:
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
This includes all sites in /etc/nginx/sites-available/ where the server{...}-blocks are defined. For more information about nginx config look at the Nginx Admin Guide.