ip-restrictions

Server socket - accept connections only from IP addresses in the whitelist

心不动则不痛 提交于 2019-12-07 02:15:31
I have a socket server that listens and accepts connections from client, which works as follow: ... do some pre-processing (socket, binds, etc) //listen to client if (listen(sockfd, BACKLOG) == -1) { perror("listen"); exit(1); } printf("server: waiting for connections...\n"); while(1) { // main accept() loop sin_size = sizeof client_addr; new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size); if (new_fd == -1) { perror("accept"); continue; } //do something ..... ..... } How can I restrict the server so it only accepts connection from specific IP addresses? For instance, I can

IP restriction for a folder of a web application, in IIS7

烂漫一生 提交于 2019-12-01 15:16:27
问题 I have a web application, in which a web service resides in a folder. The whole web application can be accessed from anywhere, while the web service should only be accessed from certain IP addresses. I can't separate them and take the web service into another IIS web site, thus I need to restrict the access to the web service, while it resides in that web site. However, I have no limitation in creating virtual directories . What should I do? Can I do it at all? To understand the scenario

Restrict / Block Directory Based on IP Address

天涯浪子 提交于 2019-11-29 15:34:30
Trying to block directory access from everyone except 1 IP address. This .htaccess code blocks access but it blocks access to everything including images, css, etc. What do I need to change? RewriteCond %{REMOTE_ADDR} !^XX\.XXX\.XX\.XXX$ RewriteRule ^hidedirectory(.*)$ http://site.com/ [R,L] Anyone accessing mysite.com/hidedirectory except me should redirect to mysite.com. Is there a better, more secure way to do this including something like an http response code? Better way is to do this in your .conf file: <Directory /hidedirectory> options -Indexes Order Deny,Allow Deny from all Allow from