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.
Related
nginx image is capturing logs which are being forwarded using symlinks to /dev/stdout and /dev/stderror this will be presented to the Rancher UI Logs console for this deployment
I need to forward instead to a fluentd pod which is already successfully collecting logs from other pods
Any given help will be very much appreciated
######################## nginx pod and logs location ########################
/var/log/nginx # ls -hal
total 0
drwxr-xr-x 2 root root 41 Oct 18 2016 .
drwxr-xr-x 1 root root 19 Oct 18 2016 ..
lrwxrwxrwx 1 root root 11 Oct 18 2016 access.log -> /dev/stdout
lrwxrwxrwx 1 root root 11 Oct 18 2016 error.log -> /dev/stderr
######################## nginx conf ########################
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;
}
Tried different changes to the configuration files but cannot find the way to forward the logs to a fluentd pod which is already collecting logs from other deployments in the same namespace
Tried with a different nginx.conf but still cannot see the log forwarded to fluentd/mongodb syslog pod
Others pods forward without issues to fluentd/mongo and is possible to see the logs on their collections, only this nginx pod is the one not forwarding, the other pods are not nginx proxies
Any given help will be very much appreciated, as per below nginx and fluentd config files
I can ping nginx.namespace.svc and fluentd.namespace.svc from/to each other
<pre><code>
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 escape=json
'{'
'"time_local":"$time_local",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
'"request":"$request",'
'"status": "$status",'
'"body_bytes_sent":"$body_bytes_sent",'
'"http_referrer":"$http_referer",'
'"http_user_agent":"$http_user_agent",'
'"request_time":"$request_time"'
'}';
access_log syslog:server=fluentd.namespace.svc:24224 main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
</code></pre>
<pre><code>
<source>
#type forward
#id inputDocker
#label #DOCKER
port 24224
bind 0.0.0.0
</source>
<label #DOCKER>
<match **>
# plugin type
#type mongo
# mongo db connection string
connection_string mongodb://logging:password#mongodb.namespace.svc:27017/logs
# mongodb db + collection
collection docker
# interval
<buffer>
flush_interval 10s
</buffer>
# make sure to include the time key
<inject>
time_key time
</inject>
</match>
</label>
</code></pre>
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.
we are configuring customized the nginx, while validating the nginx i'm getting below error
nginx -t
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: [warn] conflicting server name "gmottqa.test.att.com" on 0.0.0.0:8080, ignored
nginx: [warn] conflicting server name "gmottqa.test.att.com" on 0.0.0.0:8443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Adding nginx config file for troubleshooting the issue, please let me know if anything requried
cat nginx.conf
user nginx;
worker_processes auto;
error_log /opt/app/nginx/logs/error.log error;
pid /opt/app/nginx/run/nginx.pid;
events {
worker_connections 4096;
multi_accept on;
use epoll;
}
worker_rlimit_nofile 400000;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
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 /opt/app/nginx/logs/access.log main;
keepalive_timeout 15;
keepalive_requests 1024;
client_header_timeout 15;
client_body_timeout 15;
send_timeout 15;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
# enable gzip compression
gzip off;
gzip_http_version 1.1;
gzip_vary on;
gzip_proxied any;
gzip_static on;
# end gzip configuration
include /opt/app/nginx/conf/conf.d/*.conf;
can you please some where i have check this issue
I assume, you're using Linux.
In the /etc/nginx/sites-enabled, depending on your editor it may have left a temp file e.g. default~ or the file could be named .save or something like this.
Just run $ ls -lah to see which files are unintended to be there.
Delete this file, it should solve your problem.
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
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.