Не удалось запустить лак - PullRequest
0 голосов
/ 30 мая 2018

Я установил Varnish на сервер Nginx (Centos 7).Я настроил порты следующим образом: я изменил порт прослушивания Nginx на 8080 и изменил порт прослушивания Varnish на 80. Затем я остановил оба Nginx и Varnish.Затем я сначала запустил Nginx, а затем запустил Varnish.Nginx запускается без ошибок, но Varnish не запускается.Когда я проверяю журналы, он говорит, что порт 80 используется с другим процессом.И когда я проверяю, какой процесс использует порт 80, я вижу, что Nginx использует порт 80, даже если я изменил порт прослушивания nginx.Когда я впервые начал Varnish (после их остановки), я не смог запустить Nginx на этот раз.Ниже приведены мои конфигурации nginx.conf и nginx доменов:

nginx.conf:

user  nginx;
worker_processes  auto;
#worker_priority -10;
worker_rlimit_nofile 100000;

timer_resolution 100ms;

error_log  /var/log/nginx/error.log crit;
pid        /var/run/nginx.pid;

#load_module modules/ngx_http_modsecurity_module.so;
events {
    worker_connections  3500;
    use epoll;
    #accept_mutex on;
    #accept_mutex_delay 200ms;
    multi_accept on;
}


http {
    charset utf-8;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
include /etc/nginx/conf/ddos1.conf;
    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 off;
    sendfile on;
    sendfile_max_chunk 512k;
    tcp_nopush on;
    tcp_nodelay on;
    types_hash_max_size 2048;
    server_tokens off;
    server_name_in_redirect off;
    server_names_hash_bucket_size 128;
   open_file_cache max=130000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    open_log_file_cache max=10000 inactive=30s min_uses=2;
    output_buffers   8 256k;
    postpone_output  1460;
    request_pool_size  32k;

    connection_pool_size  512;
    directio 4m;


    client_body_buffer_size 256k;
    client_body_timeout 60;
    client_header_buffer_size 64k;
    client_body_in_file_only off;
    large_client_header_buffers 4 256k;
    client_header_timeout  20;
    ignore_invalid_headers on; 
client_max_body_size 200m;


    keepalive_timeout 25;
    keepalive_requests 1000;
    keepalive_disable msie6;
    lingering_time 20s;
    lingering_timeout 5s;
    reset_timedout_connection on;
    send_timeout 50;


    gzip on;
    gzip_static on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 5;
    gzip_buffers 32 8k;
    gzip_min_length 1024;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


    limit_req_zone  $http_x_forwarded_for zone=zone:10m rate=5r/s;

  # Cloudflare module cho nginx
    set_real_ip_from   204.93.240.0/24;
    set_real_ip_from   204.93.177.0/24;
    set_real_ip_from   199.27.128.0/21;
    set_real_ip_from   173.245.48.0/20;
    set_real_ip_from   103.21.244.0/22;
    set_real_ip_from   103.22.200.0/22;
    set_real_ip_from   103.31.4.0/22;
    set_real_ip_from   141.101.64.0/18;
    set_real_ip_from   108.162.192.0/18;
    set_real_ip_from   190.93.240.0/20;
    set_real_ip_from   188.114.96.0/20;  
    set_real_ip_from   197.234.240.0/22;
    set_real_ip_from   198.41.128.0/17;
    set_real_ip_from   162.158.0.0/15;
    set_real_ip_from   104.16.0.0/12;
    set_real_ip_from   2400:cb00::/32;
    set_real_ip_from   2606:4700::/32;
    set_real_ip_from   2803:f800::/32;
    set_real_ip_from   2405:b500::/32;
    set_real_ip_from   2405:8100::/32;
    #real_ip_header     CF-Connecting-IP;
    real_ip_header X-Forwarded-For;


    include /etc/nginx/conf.d/*.conf;
}

Пример конфигурации домена Nginx в папке /etc/nginx/conf.d/ (www.sitename.com.conf):

server {
        server_name servername.com;
        rewrite ^(.*) http://www.servername.com$1 permanent;
        }
server {
        listen   8080;
        access_log off;
        # access_log   /home/www.servername.com/logs/access_log;
        error_log off;
        # error_log /home/www.servername.com/logs/error.log;    
        #add_header X-Frame-Options SAMEORIGIN;
        add_header X-Frame-Options "ALLOW-FROM https://www.sitename.com";
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        root /home/www.servername.com/public_html;
        include /etc/nginx/conf/ddos2.conf;
        index index.php index.html index.htm;
        server_name www.servername.com;

Как я могу определенно изменить порт Nginx?

...