Articles in this section

Nginx shows warning when running nginx -t: nginx: [warn] protocol options redefined for 203.0.113.2

kb: bug kb: fixed

Symptoms

  • The following warning shows up when running nginx -t via CLI:

    # nginx -t
    nginx: [warn] protocol options redefined for 203.0.113.2:443 in /etc/nginx/plesk.conf.d/vhosts/example.com.conf:7
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

  • Server preference http2 is enabled:

    # plesk bin http2_pref --status
    Enabled

  • Preferred domain is set to example.com in Domains > example.com > Hosting & DNS > Hosting

  • Running command plesk bin http2_pref --enable may fix the warning temporarily, but will show up again.

Cause

Product issue:

  • PPPM-14042 "Enabling HTTP/2 no longer results in the œ'protocol options redefined' warning."
    Fixed in:

Resolution

Please consider updating your server:

Workaround

If update is not possible for some reason you may try the following

workaround

Use Event Handlers to update nginx configuration files:

  1. Connect to the server via SSH

  2. Create and Edit file /root/update_nginx.sh that will be used by the Event Handler:

    CONFIG_TEXT: #!/bin/bash
    vhostDir=$(grep VHOST /etc/psa/psa.conf | awk {'print $2'})
    if [ ! -z "$vhostDir" ] ; then
    sleep 15
    find $vhostDir/system/*/conf -type f -name "nginx.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
    find /etc/nginx/plesk.conf.d/webmails/ -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
    find /etc/nginx -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
    else
    echo "Vhost DIR fetch failed. Exiting ..." && exit 0
    fi

  3. Set executable permissions to the script:

    # chmod +x /root/update_nginx.sh

  4. Log into Plesk

  5. Create Event Handler by going to Tools & Settings > Event Manager > Add Event Handler and add the following details:

    • Event: Physical hosting created
    • Priority: 50
    • User: root
    • Command: /root/update_nginx.sh
  6. Repeat step 5 for Event: Physical hosting updated

  • Optionally it is possible to force the nginx configuration files update immediately by running the script manually once:

    # /root/update_nginx.sh

Was this article helpful?

Comments

2 comments
Date Votes
  • How about fixing the already existing hostings? (I think the above script fixes ALL of the hostings actually.)

    I manually ran the script, but it now complains about ipv6 addresses..

    nginx: [warn] protocol options redefined for [2a01:xxx:xxx:xxx::2]:443 in /etc/nginx/plesk.conf.d/vhosts/domain.com.conf:183
    (repeats for pages)

    0
  • To fix IPv6 too using the workaround above, you can use this in step 2 as the code above is only working for IPv4;

    #!/bin/bash
    vhostDir=$(grep VHOST /etc/psa/psa.conf | awk {'print $2'})
    if [ ! -z "$vhostDir" ] ; then
            sleep 15
            find $vhostDir/system/*/conf -type f -name "nginx.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
            find $vhostDir/system/*/conf -type f -name "nginx.conf" | xargs -i sed -i '/http2/!s/\(listen \[[0-9a-f:]*\]:443 ssl\)/\1 http2/' {}
            find /etc/nginx/plesk.conf.d/webmails/ -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
            find /etc/nginx/plesk.conf.d/webmails/ -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen \[[0-9a-f:]*\]:443 ssl\)/\1 http2/' {}
            find /etc/nginx -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen [0-9.]*:443 ssl\)/\1 http2/' {}
            find /etc/nginx -type f -name "*.conf" | xargs -i sed -i '/http2/!s/\(listen \[[0-9a-f:]*\]:443 ssl\)/\1 http2/' {}
    else
            echo "Vhost DIR fetch failed. Exiting ..." && exit 0
    fi
    0

Please sign in to leave a comment.