Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Thursday, July 12, 2007

Getting the program name that is listening on a specified port

Sometimes we need to find out which program is listening on a specified port.

In Linux, we can use:
netstat -natlp

-n, --numeric don't resolve names
-a, --all, --listening display all sockets (default: connected)
< Socket >={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
-l, --listening display listening server sockets
-p, --programs display PID/Program name for sockets

In windows, we can use fport which can be downloaded in the internet.

Its official website: http://www.foundstone.com/us/resources-free-tools.asp

Friday, July 6, 2007

Website visited statistics

For counting the visited amount, first of all, add one configuration in config/environment.rb
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", "daily")

1. get the request statistics
cat production.log.20070702|grep "200 OK"|wc -l

2. get the URL visited statistics
cat production.log.20070702 | grep "200 OK" | awk '{print $17}'|sort|uniq -c | sort -r -n > stat.log

Thursday, June 14, 2007

DNS Configuration in Fedora 4

This is only to set up a DNS environment for an application testing, so it only setup a simple domain look up function, and doesn't use so much functions, such as bind-chroot

DNS setup steps:

1. Design the mapping between domain name and IP address. Here, I use zhanqiang.net and 192.168.1.110;

2. Check if BIND(Berkeley Internet Name Domain) has been installed: rpm -qa | grep bind

3. Add some lines in /etc/named.conf

change
=======================================
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
include "/etc/rndc.key";

=======================================
to
=======================================
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};

zone "zhanqiang.net" IN {
type master;
file "zhanqiang.net.zone";
allow-update { none; };
};

include "/etc/rndc.key";
=======================================

4. create and edit /var/named/zhanqiang.net.zone
=======================================
$TTL 86400
@   IN  SOA   dns.zhanqiang.net.  root.zhanqiang.net. (
1997022700 ; Serial
28800 ; Refresh
7000 ; Retry
1800000 ; Expire
86400 ) ; Minimum

@  IN  NS    dns.zhanqiang.net.
@  IN MX 10   dns.zhanqiang.net.
dns    IN A 192.168.1.110
www    IN CNAME     dns
=======================================

5. restart named(DNS) service: service named restart

6. check firewall if the port 53 has been blocked;

7. run neat or edit /etc/resolve.conf for changing the network card DNS setting in order to use the DNS service in 192.168.1.110

8. test the DNS with ping, host, and nslookup commands

Now it is done.

Monday, May 28, 2007

RoR: lighttpd proxy setting

For accessing other servers' resources transparently, setting up the web server to support reverse proxy.

In lighttpd, the steps:
1. add 'mod_proxy' in server module group;
2. set up the server as:
=================================================
$HTTP["host"] == "rails.qiang.com" {
server.document-root = "/rails/sample/public"
url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
server.error-handler-404 = "/dispatch.fcgi"
server.errorlog = "/rails/sample/lighttpd.log"
fastcgi.server = ( ".fcgi" =>
( "localhost" =>
(
"min-procs" => 2,
"max-procs" => 4,
"socket" => "/tmp/stage-fcgi.socket",
"bin-path" => "/rails/sample/public/dispatch.fcgi",
"bin-environment" => ("RAILS_ENV" => "rail")
)
))

proxy.server = ( "/other" => ( "other" => ("host" => "1.1.1.1/other", "port" => 80)))
}
=================================================

For apache, please read the followed link: http://www.apachetutor.org/admin/reverseproxies.