Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continous PHP errors: inet_ntop() and inet_pton() #7090

Closed
janis91 opened this issue Nov 6, 2017 · 16 comments
Closed

Continous PHP errors: inet_ntop() and inet_pton() #7090

janis91 opened this issue Nov 6, 2017 · 16 comments

Comments

@janis91
Copy link

janis91 commented Nov 6, 2017

I have a question regarding continously occuring errors in my nextcloud log.

What can cause such a behaviour? Is it a wrong configuration on my side or is it a bug on NC side?

Expected behaviour

No errors.

Actual behaviour

Errors.

Server configuration

Operating system:
debian stretch.

Web server:
nginx

Database:
psql 9.6

PHP version:
7.0

Nextcloud version: (see Nextcloud admin page)
12.0.3

Updated from an older Nextcloud/ownCloud or fresh install:
11 (yes)

Where did you install Nextcloud from:
upgrade (downloaded package before)

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - activity: 2.5.2
  - admin_audit: 1.2.0
  - bruteforcesettings: 1.0.2
  - comments: 1.2.0
  - dav: 1.3.0
  - federatedfilesharing: 1.2.0
  - files: 1.7.2
  - files_accesscontrol: 1.2.5
  - files_automatedtagging: 1.2.2
  - files_pdfviewer: 1.1.1
  - files_sharing: 1.4.0
  - files_texteditor: 2.4.1
  - files_trashbin: 1.2.0
  - files_versions: 1.5.0
  - files_videoplayer: 1.1.0
  - firstrunwizard: 2.1
  - gallery: 17.0.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.0.0
  - nextcloud_announcements: 1.1
  - notifications: 2.0.0
  - oauth2: 1.0.5
  - password_policy: 1.2.2
  - provisioning_api: 1.2.0
  - serverinfo: 1.2.0
  - sharebymail: 1.2.0
  - survey_client: 1.0.0
  - systemtags: 1.2.0
  - theming: 1.3.0
  - twofactor_backupcodes: 1.1.1
  - updatenotification: 1.2.0
  - workflowengine: 1.2.0
Disabled:
  - encryption
  - federation
  - files_external
  - user_external
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "updatechecker": true,
        "instanceid": "ocv0ur7aftek",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***.de",
            "www.***REMOVED SENSITIVE VALUE***.de"
        ],
        "datadirectory": "\/var\/nextcloud_data",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***.de",
        "dbtype": "pgsql",
        "version": "12.0.3.3",
        "dbname": "owncloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***.de",
        "loglevel": 2,
        "theme": "",
        "maintenance": false,
        "htaccess.RewriteBase": "\/nextcloud",
        "mail_smtpsecure": "ssl",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "updater.release.channel": "stable",
        "mail_from_address": "nextcloud",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

Are you using external storage, if yes which one: nfs

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Client configuration

different clients as in the logs.

Logs

Web server error log

Web server error log
no errors in the log. and access_log is not really more verbose than NC.

Nextcloud log (data/nextcloud.log)

Nextcloud log
{
   "reqId":"Iuuzx8e4cE7a89bAJf9b",
   "level":3,
   "time":"2017-11-06T19:14:00+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"GET",
   "url":"\/nextcloud\/ocs\/v1.php\/cloud\/capabilities?format=json",
   "message":"inet_pton(): Unrecognized address  at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#69",
   "userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.2 (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}{
   "reqId":"Iuuzx8e4cE7a89bAJf9b",
   "level":3,
   "time":"2017-11-06T19:14:00+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"GET",
   "url":"\/nextcloud\/ocs\/v1.php\/cloud\/capabilities?format=json",
   "message":"inet_ntop(): Invalid in_addr value at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#77",
   "userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.2 (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}{
   "reqId":"98C6cReVEa2yTjIczFEf",
   "level":3,
   "time":"2017-11-06T19:14:01+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"GET",
   "url":"\/nextcloud\/ocs\/v1.php\/cloud\/user?format=json",
   "message":"inet_pton(): Unrecognized address  at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#69",
   "userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.2 (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}{
   "reqId":"98C6cReVEa2yTjIczFEf",
   "level":3,
   "time":"2017-11-06T19:14:01+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"GET",
   "url":"\/nextcloud\/ocs\/v1.php\/cloud\/user?format=json",
   "message":"inet_ntop(): Invalid in_addr value at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#77",
   "userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.2 (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}{
   "reqId":"ZI16k0sjg17OiBgCu8hQ",
   "level":3,
   "time":"2017-11-06T19:16:32+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"POST",
   "url":"\/nextcloud\/login",
   "message":"inet_pton(): Unrecognized address  at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#69",
   "userAgent":"Mozilla\/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko\/20100101 Firefox\/56.0",
   "version":"12.0.3.3"
}{
   "reqId":"ZI16k0sjg17OiBgCu8hQ",
   "level":3,
   "time":"2017-11-06T19:16:32+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"POST",
   "url":"\/nextcloud\/login",
   "message":"inet_ntop(): Invalid in_addr value at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#77",
   "userAgent":"Mozilla\/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko\/20100101 Firefox\/56.0",
   "version":"12.0.3.3"
}{
   "reqId":"dajQfJVDdpIjUZTPGe0P",
   "level":3,
   "time":"2017-11-06T19:38:56+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"PROPFIND",
   "url":"\/nextcloud\/remote.php\/dav\/files\/Janis\/",
   "message":"inet_pton(): Unrecognized address  at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#69",
   "userAgent":"Mozilla\/5.0 (Macintosh) mirall\/2.3.3beta (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}{
   "reqId":"dajQfJVDdpIjUZTPGe0P",
   "level":3,
   "time":"2017-11-06T19:38:56+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"PROPFIND",
   "url":"\/nextcloud\/remote.php\/dav\/files\/Janis\/",
   "message":"inet_ntop(): Invalid in_addr value at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#77",
   "userAgent":"Mozilla\/5.0 (Macintosh) mirall\/2.3.3beta (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}
@MorrisJobke
Copy link
Member

@janis91 What is the remoteAddr in those cases? (see the log file) It is fine to replace some numbers/characters in there, but they should be the same (for example exchange a letter for a letter, or a digit for another digit, but don't replace a dot or a colon)

@janis91
Copy link
Author

janis91 commented Nov 7, 2017

12.123.123.123 - Janis [06/Nov/2017:18:13:59 +0100] "GET /nextcloud/ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 200 553 "-" "Mozilla/5.0 (Windows) mirall/2.3.2 (build 1) (Nextcloud)"
12.123.123.123 - - [06/Nov/2017:18:16:31 +0100] "GET /nextcloud/login HTTP/2.0" 200 3856 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0"

...only to show a few (of course I changed the IP here, but there is nothing wrong with it, I would say).

Maybe the nginx site config helps:

upstream php-handler {
    server unix:/run/php/php7.0-fpm.sock;
}

server {
    listen 80;
    server_name ***REMOVED SENSITIVE VALUE***;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name ***REMOVED SENSITIVE VALUE*** ***REMOVED SENSITIVE VALUE***;

    ssl on;
	ssl_certificate /etc/letsencrypt/live/***REMOVED SENSITIVE VALUE***/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/***REMOVED SENSITIVE VALUE***/privkey.pem;
    ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4';
    ssl_prefer_server_ciphers on;
	ssl_session_cache shared:le_nginx_SSL:1m;
	ssl_session_timeout 1440m;
    ssl_dhparam /etc/ssl/private/dhparams.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
	add_header X-Frame-Options "SAMEORIGIN";

    # Path to the root of your installation
    root /var/www/;
	
    index index.html;

    location = /favicon.ico {
        alias /var/www/favicon.ico;
    }
	
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    # rewrite ^/.well-known/host-meta /nextcloud/public.php?service=host-meta
    # last;
    #rewrite ^/.well-known/host-meta.json
    # /nextcloud/public.php?service=host-meta-json last;

    location = /.well-known/carddav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    }

    location /.well-known/acme-challenge { }

    location ^~ /nextcloud {

        # set max upload size
        client_max_body_size 512M;
        fastcgi_buffers 64 4K;
		
		error_page 403 /nextcloud/core/templates/403.php;
        error_page 404 /nextcloud/core/templates/404.php;

        # Enable gzip but do not remove ETag headers
        gzip on;
        gzip_vary on;
        gzip_comp_level 4;
        gzip_min_length 256;
        gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
        gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        location /nextcloud {
            rewrite ^ /nextcloud/index.php$uri;
        }

        location ~ ^/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
            deny all;
        }
        location ~ ^/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console) {
            deny all;
        }

        location ~ ^/nextcloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param HTTPS on;
            #Avoid sending the security headers twice
            fastcgi_param modHeadersAvailable true;
            fastcgi_param front_controller_active true;
            fastcgi_pass php-handler;
            fastcgi_intercept_errors on;
            fastcgi_request_buffering off;
			# Raise timeout values.
			# This is especially important when the ownCloud setup runs into timeouts (504 gateway errors)
			fastcgi_read_timeout 300;
			fastcgi_send_timeout 300;
			fastcgi_connect_timeout 300;
			
			# Pass PHP variables directly to PHP.
            # This is usually done in the php.ini. For more flexibility, these variables are configured in the nginx config.
			# All the PHP parameters have to be set in one fastcgi_param. When using more 'fastcgi_param PHP_VALUE' directives, the last one will override all the others.
            fastcgi_param PHP_VALUE "open_basedir=/var/www:/tmp/:/var/nextcloud_data:/dev/urandom
 upload_max_filesize = 1G
 post_max_size = 1G
 max_execution_time = 3600";
 
			fastcgi_param REMOTE_ADDR $http_x_real_ip;
        }

        location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
            try_files $uri/ =404;
            index index.php;
        }

        # Adding the cache control header for js and css files
        # Make sure it is BELOW the PHP block
        location ~ \.(?:css|js|woff|svg|gif)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            add_header Cache-Control "public, max-age=15778463";
            # Add headers to serve security related headers  (It is intended
            # to have those duplicated to the ones above)
            # Before enabling Strict-Transport-Security headers please read
            # into this topic first.
            add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
            add_header X-Content-Type-Options nosniff;
            add_header X-XSS-Protection "1; mode=block";
            add_header X-Robots-Tag none;
            add_header X-Download-Options noopen;
            add_header X-Permitted-Cross-Domain-Policies none;
			add_header X-Frame-Options "SAMEORIGIN";

            # Optional: Don't log access to assets
            access_log off;
        }

        location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            # Optional: Don't log access to other assets
            access_log off;
        }
    }
}

@MorrisJobke

@j-ed
Copy link
Contributor

j-ed commented Nov 7, 2017

@janis91 All kind of problems have been reported in the past when you're using HTTP/2 to access Nextcloud. So my recommendation is to give HTTP/1.1 a try first, to narrow down the problem. See e.g. #6817 (comment)

@janis91
Copy link
Author

janis91 commented Nov 7, 2017

@j-ed if there are issues with http2 and nextcloud (the issues referenced by you seem to be solved) I don't get why the confiuration sample in the docs are for http2: https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html
Beside that: my whole seever works and the performance is also really good for a raspberry pi (btw). There isn't an issue at all beside those annoying error logs I mentioned. They arenpolluting the whole log space.

@j-ed
Copy link
Contributor

j-ed commented Nov 7, 2017

@janis91 It was only a shot in the dark from my side. As far as I see you haven't told us the architecture (Raspberry Pi) nor the Nginx version in your original issue ticket. How will you know that the issue I referred to has been solved on your system you're not hit by it?

Would it be possible that you also provide the exact error message from the log file?

@janis91
Copy link
Author

janis91 commented Nov 7, 2017

@j-ed There was no offense. I just think, that if it is really a problem with http2 it would be worth finding out the reason. http2 is much better in many different aspects, so IMHO nextcloud shouldn't lag support for it ;-) You're right that I missed to mention that I am on Raspbian and not on "real" Debian (from ssh it feels the same :-D ) and moreover I did not mention the nginx version, also right.
nginx/1.10.3
My guess is that it has something to do with the line
fastcgi_param REMOTE_ADDR $http_x_real_ip;
Originally I thought this line solves the issue, but it doesn't so my question is what could it be?

Thanks for your shot in the dark btw. :)

@j-ed
Copy link
Contributor

j-ed commented Nov 7, 2017

@janis91 Due to the fact that the functions are used to convert ip addresses I'm still interested in the real log entries and also like to know if you're using an IPv4 or IPv6 address and how it looks like in detail.

@janis91
Copy link
Author

janis91 commented Nov 7, 2017

@j-ed which logs do you mean? I already posted entries from access.log of nginx and of nextcloud.log (corresponding ones). Should I activate the debug log level?
IPv4, at least I see that it's my IP

@j-ed
Copy link
Contributor

j-ed commented Nov 7, 2017

@janis91 Sorry, my fault - The logs were folded and not instantly displayed.

@janis91
Copy link
Author

janis91 commented Nov 7, 2017

Obviously it goes through the ipv6 subnet function. why? Nginx is logging a IPv4 address.

@j-ed
Copy link
Contributor

j-ed commented Nov 7, 2017

Yes, that's what I've found too. The function 'getIPv6Subnet' is called from 'getSubnet' because the IPv4 preg_match fails. You can try to add a debug print-out to one of the functions to get hold of the parsed ip address.

@rullzer
Copy link
Member

rullzer commented Nov 8, 2017

   "reqId":"Iuuzx8e4cE7a89bAJf9b",
   "level":3,
   "time":"2017-11-06T19:14:00+00:00",
   "remoteAddr":"",
   "user":"--",
   "app":"PHP",
   "method":"GET",
   "url":"\/nextcloud\/ocs\/v1.php\/cloud\/capabilities?format=json",
   "message":"inet_pton(): Unrecognized address  at \/var\/www\/nextcloud\/lib\/private\/Security\/Normalizer\/IpAddress.php#69",
   "userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.2 (build 1) (Nextcloud)",
   "version":"12.0.3.3"
}

It seems the issue is that there is no remoteAddr set. Which is strange. Like it is filtered out.

@MorrisJobke
Copy link
Member

It seems the issue is that there is no remoteAddr set. Which is strange. Like it is filtered out.

I thought that this was sanitised by the ticket owner? @janis91 Have you removed the remoteAddr from the logs?

@janis91
Copy link
Author

janis91 commented Nov 8, 2017

@MorrisJobke @rullzer No I didn't remove any value from the nextcloud.log entries. Everywhere I removed something I used "REMOVED SENSITIVE VALUE" in order to make that clear. Whereas I masked the IP values from the access.log not by removing them, instead I changed the numbers. Everything else is left original.

@janis91
Copy link
Author

janis91 commented Nov 10, 2017

It could be, that I fixed it. I will have to do some more tests, but it might be a confguration issue of nginx that took me there. I will come back with the fix later, if I made sure, that it works.

@janis91
Copy link
Author

janis91 commented Nov 12, 2017

Fixed the issue. Finally my changes:
I changed one line in my nginx sites-available config:
FROM
fastcgi_param REMOTE_ADDR $http_x_real_ip;

TO
fastcgi_param REMOTE_ADDR $remote_addr;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants