Mitmproxy Client connection killed by block_global - proxy

Installed the latest version of mitmproxy, added cert, all like in instructions. Proxy not working, can't reach any site...what I'm doing wrong? Thanks for your time.

There is an option in mitmproxy called block_global: Block connections from globally reachable networks, as defined in the IANA special purpose registries. Default: True
https://docs.mitmproxy.org/stable/concepts-options/
You could try to set this option as false: mitmdump --set block_global=false

Related

set up conda for caching proxy (MacOs + Squidman)

How can I configure conda to use a caching proxy?
So far I have:
installed SquidMan and set its host and port to 127.0.0.1:8080.
set the network settings to proxy both http and https at this address
edited .condarc to use a proxy
I think that SquidMan is set up correctly. If I switch it off and try to browse the internet, I get an error message "The proxy server is refusing connections". This happens for both http and https websites and also if I enter an IP directly (no DNS in between).
The edited .condarc is this:
proxy_servers:
http: http://127.0.0.1:8080
https: http://127.0.0.1:8080
Those are the same addresses as in the system proxy settings - which seem to work fine for browsing.
As a test I'm cycling through
conda install python=3.6
conda install python=3.7
conda clean --all
and hoping to see very fast download speeds for those python packages.
But they are always painfully slow.
I checked the SquidMan settings. There is a "maximum object size", maybe that prevents the conda downloads from being cached. Are they too big ?
So I dialled those settings up to the max (well bigger than the conda download) and tried again. Same results.
How do I configure squidman to work with conda ?
It sounds like you likely have configured everything properly for proxying traffic through squid. However, conda uses https to download its packages. In a basic configuration, squid can only pass SSL connections through from the client to the server. This traffic is already encrypted, so it can not be cached. Options that you have available to you are:
Use squid's ssl bump feature to have squid decrypt and re-encrypt the data passing through it. Getting this set up is somewhat tricky because you have to generate a self-signed certificate and get it trusted by conda (using conda install --insecure might be all that is needed for conda).
Use a conda-specific proxy server. Anaconda, Inc. offers such a server as a product, so you are unlikely to find much built-in support for this in the open source conda tools. Sonatype's Nexus repository manager also claims to proxy conda repositories in its documentation.
Use conda's built-in support for local caching. Since you referenced conda clean in your question, you are aware of this cache and must have some reason for not using it. For a single machine, the conda pkgs_dir should work pretty well. For multiple machines, maybe you could get by with a network share pkgs_dir or copying all the .tar.bz2 and .conda files from a local machine into the pkgs_dir for each machine.
Add a second layer of proxying. conda allows you to specify channels with an http protocol. You could set up a proxy server that accepts http requests and passes them on as https requests. You could put your squid caching proxy in front of this http-https proxy. This way, squid will see plain http traffic that it can inspect and cache, and you can still access https only conda repositories. As an example, with nginx, you could do this with a simple conf file like:
server {
listen 80;
server_name localhost 127.0.0.1;
location / {
proxy_pass https://repo.anaconda.com/;
}
}

MongoDB no suitable servers found

I'm having trouble connecting to a replica set.
[MongoDB\Driver\Exception\ConnectionTimeoutException]
No suitable servers found (`serverSelectionTryOnce` set):
[Server closed connection. calling ismaster on 'a.mongodb.net:27017']
[Server closed connection. calling ismaster on 'b.mongodb.net:27017']
[Server closed connection. calling ismaster on 'c.mongodb.net:27017']
I however, can connect using MongoChef
Switching any localhost references to 127.0.0.1 helped me. There is a difference between localhost and 127.0.0.1
See: localhost vs. 127.0.0.1
MongoDB can be set to run on a UNIX socket or TCP/IP
If all else fails, what I've found that works most consistently across all situations is the following:
In your hosts file, make sure you have a name assigned to the IP address you want to use (other than 127.0.0.1).
192.168.0.101 coolname
or
192.168.0.101 coolname.somedomain.com
In mongodb.conf:
bind_ip = 192.168.0.101
Restart Mongo
NOTE1: When accessing mongo from the command line, you now have to specify the host.
mongo --host=coolname
NOTE2: You'll also have to change any references to either localhost or 127.0.0.1 to your new name.
$client = new MongoDB\Client("mongodb://coolname:27017");
I had the same error in a docker based setup:
container1: nginx listening on port 80
container2: php-fpm listening on port 9000
container3: mongodb listening on port 27017
nginx forwarding php to php-fpm
Trying to access mongodb from php gave this error.
In the mongodb Dockerfile, the culprit was:
CMD ["mongod", "--bind_ip", "127.0.0.1"]
Needed to change it to:
CMD ["mongod", "--bind_ip", "0.0.0.0"]
And the error went away. Hope this helps somebody.
The IP address of your home network may have changed, which would lead to MongoDB locking you out.
I solved this problem for myself by going to MongoDB Atlas and changing which IP address is allowed to connect to my data. Originally, I'd set it up to only allow connections from my home network. But my home network IP address changed, and I started getting the same error message as you.
To check if this is the same issue with you, go to MongoDB Atlas, go into your project, and click "Network Access" on the left hand side of the screen. That's where you're able to update your IP address. It shows you what IP address(es) it's allowing in. To find out what your current IP address is, go to whatismyipaddress.com and update MongoDB if it's different.
In my case, I am temporarily coding PHP from Windows7 against MongoDB on my VPS running Linux Debian 9. The PHP will be eventually running in the same Linux box to provide an API to the MongoDB data.
BTW, it does not appear this local composer install is doing me any good, it's pure ugliness. My PHP after the fix below works without the require line require_once 'C:\Users\<Windows User Name>\vendor\autoload.php'.
My fix is different than the accepted answer which to me did not make sense.
I did not have to touch any hosts file
So edit your /etc/mongod.conf with your target machine's IP and restart with sudo systemctl restart mongod that's it
I don't know what to blame
PHP and MongoDB sites for the terrible documentation skimpy and incomplete PHP examples, or...
MongoDB installation on Linux failing to mention this bindIP.
My startup experience with MongoDB is so far very negative given all the changes that have occurred nothing matches what I expected from the videos I watched. I can't seem to find any that reflect what I am going thru like
$DB_CONNECTION_STRING="mongodb://user:password#164.152.09.84:27017"
$m = new MongoDB\Driver\Manager( $DB_CONNECTION_STRING )
instead of
$m = new MongoClient()
Hope this helps someone
PS. Always say NO to semicolons, camelCAsE and anything case-sensitive... absurdity at its best.

Docker Installation Error on Windows behind Firewall

I'm trying to install Docker on a Windows computer but I get this message:
Running pre-create checks...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
Error with pre-create check: "Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 192.30.252.124:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."
Looks like something went wrong in step 'Checking if machine default exists'...
Press any key to continue...
Any suggestions on how to resolve this?
Editing the start.sh file may come up with other error things.
Instead that, just put your boot2docker.iso in below location as.
c:\user\USERNAME\\.docker\machine\cache
and restart your Docker terminal.
You may behind a firewall. If so, you will need to configure an http proxy.
According to https://github.com/boot2docker/boot2docker-cli/issues/230 you can do this one of a couple of ways:
(1) Edit start.sh and add the following before boot2docker.exe is called
export HTTP_PROXY=<proxy>
export HTTPS_PROXY=<proxy>
(2) Add HTTP_PROXY and HTTPS_PROXY (and their values) to your System Variables or User Variables in your Windows config.
The proxy value should be of the form http://hostname:port

setsockopt IPV6_TCLASS 16: Protocol not available, Cygwin64

I'm trying to install Hadoop 1.0.3 using Cygwin64 on Win8.1. After I completed the config, started SSHD service, I run ssh cyg_server#localhost and got these:
cyg_server#localhost's password:
setsockopt IPV6_TCLASS 16: Protocol not available:
I'm complete new with Cygwin64 and Hadoop, thanks advance for any help.
From the client side, just add
-oAddressFamily=inet
to the parameters passed to ssh, or add
AddressFamily inet
to ~/.ssh/config, either globally or per a specific host.
Basically you want to turn off IPV6 and use IPV4. To do this, stop your sshd service if you have it running:
net stop sshd
Then edit the file /etc/ssh_config by adding (or modifying) the AddressFamily setting:
AddressFamily inet
The default is set to all. Setting the value to inet forces IPV4 which fixed the problem for me. After you make the change, restart sshd and you should be good to go:
net start sshd
Good luck!
I had a simmilar issue with Cygwin logging in to IPv6-enabled Servers.
Upgrading Cygwin (on client side) to the lastest version solved my problem.
I'm tired of all the "Just disable IPv6" suggestions. We have 2014 and IPv6 is here. We should better fix bugs and issues with this "new" protocol instead of negating ist.
This error happens when OpenSSH attempts to set the "type of service" field for an IPv6 connection on a system that defines IPV6_TCLASS in <sys/socket.h>, but where the kernel doesn't support it (a 2.4-series kernel or older versions of Cygwin).
It may reduce performance in a situation where something is performing traffic shaping/QoS, but is otherwise harmless.

PHP Proxy php.ini setting

I'm trying to set get PHP running properly in a chroot jail on OSX. Because DNS lookups don't work in a chroot on OSX I would like to set all TCP connections to go through a proxy on 127.0.0.1
There is a bug report where this option was allegedly added to PHP 5
Summary: Add php.ini option to set default proxy for wrappers
However I don't seem able to find out what this option is. How do you set the default proxy for all stream wrappers?

Resources