I'm tried to using nginx on mamp, but it won't (apache is working)
Here is my setup screenshots: [][]3
Thanks in advance :)
I just try and I had the same error. I have not able to completely figured out. But on the meantime I found this solution let me know if works for you.
First I installed Brew (http://brew.sh/index_es.html)
Copy paste on your terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
When finishes running you can verify that its installed by
brew -v
Then install nginx with Brew
brew install nginx
When finishes running you can verify that its installed by
nginx -v
Now everything is supposed to be working. Now Couple of config. You go to the root folder of your machine and look for /usr/local/etc/nginx/nginx.conf open it with a text editor and you will have something like this:
(You just have to change two things the port and the url of your project)
user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080; #CHANGE TO 80
server_name localhost;
#charset koi8-r;
#access_log logs/access.log main;
location / {
root /Users/Mario/Sites/proyName; #URL of the project
}
Don't change anything else.
After this just run
sudo nginx
If you need to stop running
sudo nginx -s stop
And the URL of your project should be http://localhost
Hope it helps on the meantime
Related
Issue:-
3scale APICAST gateway deployed as a docker in AWS ec2-instance using
docker run --name apicast --rm -p 8080:8080 -e THREESCALE_PORTAL_ENDPOINT=https://<access_token>#<3scaleonprem>-admin.3scale.net registry.redhat.io/3scale-amp2/apicast-gateway-rhel8:3scale2.9
Logging into the docker as root using
sudo docker exec -it -u root container-id bash
i make the following changes to /usr/local/openresty/nginx/conf/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
lua_package_path "$prefix /lua/?.lua;;" ;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
include <nginx path>/myfolder/my.conf;
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
in my.conf
lua_need_request_body on;
set $my_response_body "";
body_filter_by_lua_file myfolder/my_body_filter.lua;
log_by_lua_file myfolder/my_log.lua;
However these lua files arent being triggered when the location / is hit from postman.Although i am able to get the response from the 3scale API management portal to which this apicast gateway is pointing.
Any reason why the nginx.conf file inside apicast docker container doesnt get triggered.Please note after making these changes i am running this to reload nginx for the changes to get reflected.
/usr/local/openresty/nginx/sbin/nginx -s reload
I have been stuck with this for quite some time.I am trying to send teh request and response to a server situated in AWS.However i aint able to even log the request or response in the logs even after trying a lot with some changes regarding logs as mentioned in nginx documentation.
Any idea if these changes have to be made somewhere else in apicast?The apicast documentation isnt at all helpful and even after browsing a lot i am unable to find the reason for this issue.
I try to deploy a Flask App on centOS with NGINX. The Flask app is served on 127.0.0.1:5000 and is also accessible with curl 127.0.0.1:5000.
I tried to keep it simple and removed all NGINX config files in conf.d and just use nginx.conf. This is the whole content of the nginx.conf file:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
#include /etc/nginx/conf.d/*.conf;
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
However, NGINX still shows its default page and there seems to be nothing in the world or at least in the nginx.conf file to change this. Is there anything in NGINX that still might require reconfiguration or anything on centOS that could lead to the problem?
I solved it. It was indeed open NGINX commands.
After I ran the following commands it worked:
sudo systemctl stop nginx
sudo systemctl enable nginx
sudo systemctl restart nginx
Maybe it helps someone in the future.
It seems like a simple problem but I cannot find any official information about how to fix it.
The problem: Deploying an EmberJS app to Nginx - all routes return 404's.
The root route / works just fine. However any route besides / fails & returns 404's. Here's how I have my nginx.conf setup:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/ivo/myapp;
index index.html;
location / {
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html?/$request_uri;
}
}
}
This config is largely based on the nginx.conf that comes with the Nginx Docker image, which I am using.
From what I understand about Nginx, the location / block should be handling my routes, but for some reason it is not.
As a side note, I am shocked that EmberJS does not have any documentation about this at all. I even tried their Nginx config from their deployment section and it too did not work - https://ember-cli.com/user-guide/#deployments
Found & "fixed" the problem. The underlying issue is that the information provided on the Nginx DockerHub page is misleading. It says:
"If you wish to adapt the default configuration, use something like the following to copy it from a running nginx container"
And it provides this line as an example:
"COPY nginx.conf /etc/nginx/nginx.conf"
However, the file located at /etc/nginx/nginx.conf was not the file I needed. Instead, the file I needed to change/replace was located here : "/etc/nginx/conf.d/default.conf"
The code I pasted above in the Question portion worked fine; it was the location that was wrong.
I am new to NGINX and I can't tell if I set my conf file up properly. I am trying to serve an index.html file located in the data/www directory. I did a lot of research and I can't seem to figure it out. I have nginx installed on a ec2 running centOS 6.5. Any pointers on how to get this up and running would be greatly appreciated. I have been trying to wrap my head around this for a while now. Thank you in advance!
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name <my elastic ip address>;
location / {
root /data/www/;
index index.html;
}
}
}
Yes,
Your Configuration file is correct.
NOTE:
working:First check your nginx server is running or not, by typing your ip:port(that you given in conf file) in browser.If running it will display nginx current version details.
ACCESS: you can access your file by using command like this.
http://your_ip_addr:port/application name/file_name
*application name:the name given for that app,
for example
location /html {
......
}
then you application name will become html.
I've just installed a CentOS 6.5 server and I've installed on it nginx.
I've disabled SELINUX and restarted the server but nginx is still not reachable from other servers except for the host itself.
This is my nginx configuration:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
}
What am I doing wrong?
Solved, there was a rule in IPTABLES that was blocking all incoming connections.
iptables -L INPUT -n --line-numbers
iptables -D INPUT <N>
service iptables save
service iptables restart
has solved the problem.