http_proxy setting - urllib2

I know this is simple.. I am jus missing something.. I give up!!
#!/bin/sh
export http_proxy='http://unblocksitesnow.info'
rm -f index.html*
strace -Ff -o /tmp/mm.log -s 200 wget 'http://slashdot.org'
I have used different proxy servers.. to no avail.. I get some default page..
In /etc/wgetrc use_proxy = on
Actually I am trying to use this setting(http_proxy) with python's urllib2. It access some default page as well..
strace - does a dns lookup of the proxy server
GET http://slashdot.org/ HTTP/1.0\r\nUser-Agent: Wget/1.11.4\r\nAccept: /\r\nHost: slashdot.org\r\n\r\n
Any pointers??

For some apps, HTTP_PROXY is case sensitive. It's best to set it in upper case.
# export HTTP_PROXY=http://server/
or
# export HTTP_PROXY=http://server:8888/

The problem was I was using proxy sites. These sites expect you to send GET request to the proxy site (with the target site as parameter in URL or whatever site specific mechanisms they implement).
I was looking for proxy sites like http://www.proxy4free.com/page1.html
I connect to their respective ports and send a get request to the original target site..

Often you need a port with the proxy-server, for example:
export http_proxy=http://unblocksitesnow.info:30000
Also, the single quotes are not needed.

On Debian/Ubuntu if you need apt-get via the proxy you will also need to update
/etc/apt/apt.conf
If the file doesnt exist, create it and apt-get update to confirm
As well as export http_proxy="<ADD>:<PORT>"

Related

Can't access Coturn web interface

I have a running coturn instance on Centos-7-x64, if I access it through the browser I can see:
TURN Server
use https connection for the admin session
After examining the documentation, I found this:
Add the admin user(s) to the database, with turnadmin utility. If you added those users, then they will be able to connect to the TURN server ports over HTTPS from your browser and perform admin tasks with the web interface.
So I created an admin user with the following command:
$ sudo bin/turnadmin -A -u username -p password
And I can see that user listed when running:
turnadmin -L
However, when I try to connect to https://my.ip.adrss:3478 I can't see the promised admin.
What am I missing here?
You need to configure TLS. For this, you can start the server with the following flags (taken from documentation)
--cert Certificate file, PEM format. Same file
search rules applied as for the configuration
file. If both --no-tls and --no-dtls options
are specified, then this parameter is not needed.
Default value is turn_server_cert.pem.
--pkey Private key file, PEM format. Same file
search rules applied as for the configuration
file. If both --no-tls and --no-dtls options
are specified, then this parameter is not needed.
Default value is turn_server_pkey.pem.
You'll need to specify the path to each file. You can find the file with find / -name turn_server_*.pem -type f, if you want to use the ones that the package comes with. Otherwise, you can point to your own files. I think they are located in /etc/turn_server_cert.pem and /etc/turn_server_pkey.pem

openshift create app ask for passwd

all. when I try 'rhc create-app demo python-2.7', I meet an issue not able to check out the git repo. system will ask for the password of the cartridge or something. but in fact I have upload the default key from openshift console.
here is what I have done:
install openshift from puppet
oo-diagnostics check pass
create app
then I remove the default files in /root/.ssh and remove the key file from openshift console, and recreate the ssh key, and run rhc setup again to upload key. then create app again, but failed again.
In the Broker Virtual Machine, while running - oo-register-dns -h node -d domainX.example.com XXX.XXX.XXX.XXX -k /var/named/domainX.example.com.key,
The proxy XXX.XXX.XXX.XXX should be your Node Virtual Machine's IP Address (as I think most probabily you have used Broker's IP Address. Change accordingly and run this command again,
It will work.
Can you try with a different (main) domain name instead of example.com? I think it might be the issue as per wikipedia explanation:
Example.com, example.net, example.org, and example.edu are second-level domain names reserved for documentation purposes and examples of the use of domain names.
Even if you've masked it with your hosts file or local DNS it still might be confusing the Openshift's DNS.

How can I play a wav sound on the server side using cgi?

How can I run a command from a (bash) CGI script to play a wav sound on the server side?
You can execute your command line audio player as described by nak, but this may not work due to the permissions of the user running Apache. By default Apache is run as www-data:www-data (or apache:apache or www:www on some distros). As a quick fix/test you can set Apache to run as a user that has permissions to access the audio device on the machine by modifying your /etc/apache2/apache2.conf (or /etc/httpd/httpd.conf") file to have:
User USER_THAT_CAN_PLAY_AUDIO
Group USER_THAT_CAN_PLAY_AUDIO
Warning: this is not secure and is not intended to be a permanent solution!
This is how I would do it
#!/bin/sh
echo Content-type: text/plain
echo ""
echo "Server is playing sine.wav!"
aplay -q sine.wav
I stumbled over this old question looking how to solve the same problem: to have my personal Apache webserver warning me when someone makes a specific request (in my case a call for chat without the need to have any IM running).
The solution below is what I use on Slackware 14.1: according to your distro YMMV.
launch visudo
add the line TheUserRunningApache ALL=(ALL) NOPASSWD: /usr/bin/play (TheUserRunningApache is the user name used by your Apache)
In the PHP page you want to play a sound add this line: system ("sudo /usr/bin/play SOUND.WAV");
If you don't want to give access to Apache to the /usr/bin folder, even if limited just to play, you can copy the sox executable (the program used to run /usr/bin/play) elsewhere, but you'll have to modify the last two instructions above accordingly.

Automatically cd to a given remote path when connecting via ssh

I have a bunch of remote servers that I regularly connect to via ssh; which I've setup in my ~/.ssh/config file. I was wondering if it was possible to specify a remote path to cd to when I connect to some of these servers?
For example, I may have something like this in my config file:
Host testbox
HostName 192.123.456.789
User root
And when I ssh in to testbox, I'd like to also cd to /var/www/apps/myapp.
I've had a look around but cannot see an option that would do that via the .ssh/config file.
Cheers,
Diego
You can do this with a tool I've open sourced that allows you to SSH and CD – aptly named sshcd. For the example you've given, you'd simply use:
sshcd root#testbox:/var/www/apps/myapp
Hope this helps!
There's an option in the authorized_keys file.
Do a man on sshd, look under the heading "AUTHORIZED_KEYS FILE FORMAT". You can add various options to each authorized key - one is command="command". As the manpage says, "Specifies that the command is executed whenever this key is used for authentication."

Cant access solr XML url from apache php

I am trying to use apache to access a XML from tomcat url like so:
http://localhost:8081/solr-example/select/?q=blah&version=2.2&start=0&rows=10&indent=on
However, I am getting a permission denied error. I have tried chown, chmod and chcon on both the tomcat and solr directories and it still gives me the error.
I am on centos/linux. Any help with this is much appreciated.
Cheers :)
Ke
Possibles solutions:
Check if the xml is under WEB-INF
directory.
Change the owner of the document to 'apache'.
PS: If you could post some of the log information, the detailed error (denied from what? the server, the SO, it's a 303 forbidden, etc) it will help.
This is due to SELinux enforcing
By default, only port 80 is allowed to do HTTP. You can add non standard ports using the command
semanage port -a -t http_port_t -p tcp 8081
I had the same issue with SOLR, which I solved using the above command.
It is explained here:
http://digitalpbk.blogspot.com/2011/10/solve-failed-to-query-solr-using-errno.html