1

I'm trying to host two separate websites from my VPS. I have two services running on different ports. What I am trying to accomplish is have nginx reverse proxy to Service A if the user types in a given URL, but reverse proxy to Service B if the user types in a different URL. Both URLs are A records to the same IP address, which points to my VPS. I have a basic config file for Nginx that I believe should be working; however, when I run nginx I get the following error message:

nginx: [emerg] bind() to [2606:4700:30::681f:5cfa]:443 failed (99: Cannot assign requiested address)

I find this very strange, because not only do I not recognize that IP address (and it is not present anywhere in my /etc directory, according to a quick grep -R), but this server doesn't even have IPv6 enabled. There are no IPv6 rules specified in my nginx configuration file.

Why could this be happening? And, how do I stop it from happening? Right now I can't run any services from this machine because this error causes nginx to close. nginx -t reports that my syntax is ok, and then exits with the same error as before.

Here is my nginx.conf. I don't have any other config files for nginx.

# 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 auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/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      blog.ericlondr.es:443 ssl http2 default_server;
        server_name blog.ericlondr.es;
        location / {
            proxy_pass  http://localhost:2368;
        }
    ssl_certificate     "/root/web/key.cert";
    ssl_certificate_key "/root/web/key";
    ssl_protocols       TLSv1.2;
    ssl_ciphers     HIGH:!aNULL:!MD5;
    }

    server {
        listen       api.ericlondr.es:443 ssl http2 default_server;
        server_name  api.ericlondr.es;
    ssl_certificate     "/root/web/key.cert";
    ssl_certificate_key "/root/web/key";
    ssl_protocols       TLSv1.2;
    ssl_ciphers     HIGH:!aNULL:!MD5;

        location ~ (/favorites|/zoop) {
            proxy_pass http://localhost:7878;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

  • By "redirect to" do you actually mean "reverse proxy to"? – Stephen Ostermiller Jan 8 at 0:49
  • Try: listen 443 ssl http2 default_server; – Richard Smith Jan 8 at 8:57
  • @StephenOstermiller Yes, I did mean that. – slondr Jan 9 at 17:42
  • Could port 443 already be in use by some other service? Maybe the message means that it can't bind to the port, rather than it can't use the iP addresss. – Stephen Ostermiller Jan 9 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.