无法启动清漆

时间:2018-05-30 17:52:02

标签: nginx varnish

我将Varnish安装到Nginx服务器(Centos 7)。我配置了这样的端口:我将Nginx监听端口更改为8080并将Varnish监听端口更改为80.然后,我停止了Nginx和Varnish。然后我先开始使用Nginx,然后开始使用Varnish。 Nginx开始没有错误,但Varnish无法启动。当我检查日志时,它说端口80与另一个进程一起使用。当我检查哪个进程使用端口80时,即使我更改了nginx侦听端口,我也看到Nginx使用端口80。当我首先开始使用Varnish时(停止它们之后),这次我无法启动Nginx。我的nginx.conf和domains 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;
}

/etc/nginx/conf.d/文件夹(www.sitename.com.conf)中的示例域Nginx配置:

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的端口?

0 个答案:

没有答案