Что имеем:
1) Система SentOS
2) Панель управления ISP Lite
3) Связка apache + nginx
4) 2 IP адресаПодскажите как правильно настроить nginx. При его запуске получаю ошибку
-bash-3.2# service nginx restart
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
Stopping nginx:. [ OK ]
Starting nginx: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use
)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
Конфиг nginx:
user nginx;
worker_processes 10;
error_log /var/log/nginx/error.log debug;
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] $status '
'"$request" $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 30;
send_timeout 900;
server_tokens off;
server {
listen 80;
server_name _;
server_name_in_redirect off;
access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwa
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;
}
}
}
http {
<------>server {
#<-----><------>listen 89.243.280.131:80;
<------><------>server_name greenet.ru www.greenet.ru;
<------><------>rewrite ^(/manager/.*)$>https://$host$1>permanent;
<------><------>location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
<------><------><------>proxy_pass http://89.243.280.131:8080;
<------><------><------>proxy_redirect http://greenet.ru:8080/ /;
<------><------><------>proxy_set_header Host $host;
<------><------><------>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_
<------><------><------>proxy_set_header X-Real-IP $remote_addr;
<------><------>}
<------><------>location / {
<------><------><------>proxy_pass http://89.243.280.131:8080;
<------><------><------>proxy_redirect http://greenet.ru:8080/ /;
<------><------><------>proxy_set_header Host $host;
<------><------><------>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_
<------><------><------>proxy_set_header X-Real-IP $remote_addr;
<------><------>}
<------><------>location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|
<------><------><------>root /var/www/val/data/www/greenet.ru;
<------><------><------>access_log /var/www/httpd-logs/greenet.ru.access.log;
<------><------><------>error_page 404 = @fallback;
<------><------>}
<------><------>location @fallback {
<------><------><------>proxy_pass http://89.243.280.131:8080;
<------><------><------>proxy_set_header Host $host;
<------><------><------>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_
<------><------><------>proxy_set_header X-Real-IP $remote_addr;
<------><------>}
<------>}
}
Конфиг httpd думаю целиком выкладывать не стоит, по этому кусоек
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname Off
RPAFproxy_ips 127.0.0.1 89.243.280.131
RPAFheader X-Real-IP
...
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to.
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 127.0.0.1:8080
Знающие люди подсказали:
В /etc/nginx/nginx.conf у Вас на 24-й строке есть запись:
listen 80;
а на 49-й строке:
listen 89.243.280.131:80;
В результате получается, что nginx первой записью занимает 0.0.0.0:80
т.е. "всё-всё на порту 80", а второй пытается занять 89.243.280.131:80
Вам нужно устранить этот конфликт и тогда nginx заработает.
Подскажите в чем тут ошибка?