Nginx反向代理服务器块不起作用

时间:2019-01-26 14:58:12

标签: nginx nginx-reverse-proxy

我为nginx设置了以下配置代码,试图将ha.hostname.org转到一台服务器和端口,将nextcloud.hostname.org转到另一台服务器,但是我似乎无法管理。我收到错误duplicate listen options for [::]:32776 in /etc/nginx/nginx.conf:76

因此,我显然做得不好,很多人谈论启用站点等,我的cof.d中只有default.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;

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}


server {
    # Update this line to be your domain
    server_name www.ha.hostname.org;
    listen [::]:32776;
    # Ensure these lines point to your SSL certificate and key
    # ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    # Use these lines instead if you created a self-signed certificate
    ssl_certificate /etc/nginx/ssl/__hostname_org.crt;
    ssl_certificate_key /etc/nginx/ssl/hostname.key;

    # Ensure this line points to your dhparams file
    ssl_dhparam /etc/nginx/ssl/dhparam.pem;


    # These shouldn't need to be changed
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    proxy_buffering off;
        location / {
        proxy_pass http://10.0.0.8:8123;
        proxy_set_header Host $host;
        proxy_redirect http:// https://;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }


}
server {
    # Update this line to be your domain
    server_name www.nextcloud.hostname.org;
    listen [::]:32776;
    # Ensure these lines point to your SSL certificate and key
    # ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    # Use these lines instead if you created a self-signed certificate
    ssl_certificate /etc/nginx/ssl/__hostname_org.crt;
    ssl_certificate_key /etc/nginx/ssl/hostname.key;

    # Ensure this line points to your dhparams file
    ssl_dhparam /etc/nginx/ssl/dhparam.pem;


    # These shouldn't need to be changed
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

            location / {
        proxy_pass https://10.0.0.25:443;
    }


}
}

0 个答案:

没有答案