Sunday, October 7, 2018

apache 2.2 - Block website with HTTPS?



I hope my question is on topic. If not, please excuse me and point me into the right direction.



Is it possible to block a site with HTTPS?



I have a website that I would like to make accessible only to myself. Of course I could solve this programatically within the system, but I was asking myself whether it was possible to force HTTPS on port 443 for asking for a certain certificate and if not provided, then return some kind of 404 error or similar. So in other words I need to have the appropriate certificate on my client system in order to be able to access the site.




Is that generally possible? If yes, could someone point me to a documentation on that? Maybe for Apache if existent?


Answer



Yep it is possible.



Here is a good tutorial.



But another, simpler way of doing this would be with a .htaccess file.


Saturday, October 6, 2018

windows - How do you free up a port being held open by dead process?

A colleague of mine recently ran into a problem where a process that had supposedly died was still bound to a network port, preventing other processes from binding to that port. Specifically, netstat -a -b was reporting that a process named System with PID 4476 had port 60001 open, except no process with PID 4476 existed, at least as far as I could tell.



Process Explorer and Task Manager did not list PID 4476 (though there was another process named System with PID 4, which had its own set of TCP connections that did not include 60001). taskkill /PID 4476 also reported that PID 4476 could not be found.




Is there a way to kill this mysterious System process to free up the port to which it's currently bound? What can cause this to happen? How can there be processes that none of Task Manager, Process Explorer, and taskkill don't know about? Rebooting managed to fix the problem, but I'd like to know if there's a way to fix this without rebooting.

hp proliant - Does the backplane on an HP server have any impact on the speed of the drives?

I have an HP Proliant DL380 Gen7. The server currently has no drives and is running on the integrated smart array controller. I was looking into replacing the controller with an LSI-9211-8i controller and adding some SATA III (6gbps) drives. I know the controller and the drives will work together but I am not sure if the backplane that the drives connect to will actually cause any kind of incompatibility.



The original spec with the server was SATA II (3gbps) / SAS 6G so thats my concern.




If there is an issue, is there anyway to resolve it?

Thursday, October 4, 2018

linux - How to setup a simple self-hosted dynamic DNS server

I have a small internal network of physical machines running hypervisors, which in turn run several KVM Ubuntu virtual machines. How would I setup an internal dynamic DNS server so that when I run a script to create a new virtual machine, that VM could automatically register itself in the DNS server?



Bind seems to be the standard DNS server for Linux, but it seems designed for a much more "static" DNS model. Dynamically updating this would require a complicated script that would have to SSH into the DNS server, edit configuration files, and then restart the server. This doesn't seem like a very elegant solution. Are there better options?



I saw a similar question, although they're asking for a solution for a public setting on Amazon. My servers are entirely private, and I don't want to rely on an external VM host or Dynamic DNS provider.

networking - Network ACLs for private subnet (with NAT Gateway)

I have created two subnets in my vpc (10.11.0.0/22)




  • public subnet - 10.11.0.128/27

  • private subnet - 10.11.0.0/26



I have also created the NAT gateway in public subnet and attached it to private subnet so that instances in private subnet can access the internet.



So everything is working, I have created Linux instance in public subnet and I can do ssh and also access internet. Same is the case with private subnet instances, I can login to private instances through public instances.




But after applying Network ACLs



Inbound Rules



Inbound Rules



Outbound Rules



Outbound Rules




I can access the internet from my public instances but could not access it through the private instance.



What would be correct Network ACLs for in order to access internet from private instances?

Monday, October 1, 2018

nginx - ubuntu: Installed php-mcrypt but it doesn't show up in phpinfo()

A web app I'm trying to install on my ubuntu 10.04 LTS requires mcrypt, and is generating this error: Fatal error: Call to undefined function mcrypt_module_open(). I know this is the same question as this one: Installed php-mcrypt but it doesn't show up in phpinfo(), but I tried several things, none of which worked, and have additional questions. I would comment on the original thread but don't have enough reputation to do so; forgive me for the duplicate question.



My versions of php and mcrypt are (both installed via apt-get):



php: 5.3.2-1ubuntu4.10
mcrypt: 5.3.2-0ubuntu



Doing a php -m shows that the mcrypt module is installed. I installed mcrypt and php5-mcrypt via apt-get.



Also, I'm using nginx as my web server. I have tried reinstalling mcrypt and restarting nginx, but still can't get mcrypt to show up on phpinfo() and calls to mcrypt are still broken.



Here is some more info:



$ php -i | grep "mcrypt"
/etc/php5/cli/conf.d/mcrypt.ini,
mcrypt

mcrypt support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value


I also checked that mcrypt is on in /etc/php5/cli/conf.d/mcrypt.ini and /etc/php5/cgi/conf.d/mcrypt.ini.



Lastly, I'm using fastCGI with nginx. I googled around and saw suggestions to restart php5-fpm. I couldn't find php5-fpm in apt-get, I'm not sure if I still need php5-fpm since I already have fastCGI.



Is there anything else I'm missing?

linux - mdadm RAID6, recover 2 disk failure during reshape

I was reshaping my array from 10 disks to 11 to a degraded state (drive I want to add already has data on it, but nowhere to put it). 2 drives disconnected while it was running (power issue).




Is it still possible to recovery this array?



After power cycling them I was unable to add them to the array again:



mdadm: /dev/md0 has failed so using --add cannot work and might destroy
mdadm: data on /dev/sdX1. You should stop the array and re-assemble it.


Since rebooting, I've tried:




--assemble, fails due to "faulty" disks



--assemble --force, fails:



md: sdl1 does not have a valid v1.2 superblock, not importing!
md: sdk1 does not have a valid v1.2 superblock, not importing!
md/raid:md0: not enough operational devices (3/11 failed)
md/raid:md0: failed to run raid set.`



I've been reading the RAID Recovery article, but so far not been successful.



mdadm --create --chunk=64 --size=1953512448 --assume-clean --level=6 --raid-devices=11 /dev/md0 /dev/sd{f,h,e,g,m,i,k,l,n,d}1 missing, fails:



mdadm: /dev/sdf1 is smaller than given size. 1953512256K < 1953512448K + metadata


for all drives. My argument to --size is "Used Dev Size / 2" from mdadm --examine /dev/sdf1. I've downgraded mdadm to each version down to v3.1.2 (when default metadata was changed to 1.2, I know I never specified it manually).




Removing --size, I can create the array, but not mount:



XFS (md0): Mounting V4 Filesystem
XFS (md0): Log inconsistent (didn't find previous header)
XFS (md0): failed to find log head
XFS (md0): log mount/recovery failed: error -5
XFS (md0): log mount failed


Info




My mdadm --detail before reshape:



/dev/md0:
Version : 1.2
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Array Size : 15628099584 (14904.12 GiB 16003.17 GB)
Used Dev Size : 1953512448 (1863.01 GiB 2000.40 GB)
Raid Devices : 10

Total Devices : 10
Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Wed Jun 17 14:16:09 2015
State : clean
Active Devices : 10
Working Devices : 10
Failed Devices : 0

Spare Devices : 0

Layout : left-symmetric
Chunk Size : 64K

Name : ubuntu:0
UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Events : 6037532

Number Major Minor RaidDevice State

0 8 81 0 active sync /dev/sdf1
9 8 177 1 active sync /dev/sdl1
12 8 65 2 active sync /dev/sde1
3 8 97 3 active sync /dev/sdg1
4 8 145 4 active sync /dev/sdj1
6 8 193 5 active sync /dev/sdm1
7 8 113 6 active sync /dev/sdh1
8 8 129 7 active sync /dev/sdi1
10 8 161 8 active sync /dev/sdk1
11 8 49 9 active sync /dev/sdd1



And mdadm --examine after failure and reboot with all disks visible again:



Device paths have changed as there was a hotswap disk added before reshape started



/dev/sdd1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5

Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors

State : clean
Device UUID : 329fc32d:e9cf2ff4:3aa6c9a0:500aa445

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:46:34 2015
Checksum : 904d0c9c - correct
Events : 6039833


Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 9
Array State : A.AAA...AA. ('A' == active, '.' == missing)


/dev/sde1:
Magic : a92b4efc

Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)

Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : e59303ea:e613013e:ef8af657:1fc6ccab

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:46:34 2015

Checksum : b3b3f659 - correct
Events : 6039833

Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 2
Array State : A.AAA...AA. ('A' == active, '.' == missing)



/dev/sdf1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11


Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 6aa0f9d8:e7b0cc66:d2f2a600:ef305279

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3148373376 (3002.52 GiB 3223.93 GB)
Delta Devices : 1 (10->11)


Update Time : Wed Jun 17 19:46:34 2015
Checksum : 3beac20c - correct
Events : 6039833

Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 0
Array State : AAAAAAAAAA. ('A' == active, '.' == missing)



/dev/sdg1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6

Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 4b1d87a9:16027400:df71810f:3ce53c50

Internal Bitmap : 2 sectors from superblock

Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:46:34 2015
Checksum : 91a563ea - correct
Events : 6039833

Layout : left-symmetric
Chunk Size : 64K


Device Role : Active device 3
Array State : A.AAA...AA. ('A' == active, '.' == missing)


/dev/sdh1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0

Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 5860268032 (2794.39 GiB 3000.46 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Used Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean

Device UUID : 27c8fefa:8b2b74a2:9a456d34:d1a60c20

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:29:09 2015
Checksum : ee4ae103 - correct
Events : 6039833


Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 1
Array State : AAAAAA..AA. ('A' == active, '.' == missing)


/dev/sdi1:
Magic : a92b4efc
Version : 1.2

Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors

Super Offset : 8 sectors
State : clean
Device UUID : bebc3764:9e582fe8:01de9766:2d8c452b

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:29:09 2015
Checksum : 6632686d - correct

Events : 6039833

Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 5
Array State : AAAAAA..AA. ('A' == active, '.' == missing)


/dev/sdk1:

Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 5860268032 (2794.39 GiB 3000.46 GB)

Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Used Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 986d9f31:3a74b90d:7800779e:31607539

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3148373376 (3002.52 GiB 3223.93 GB)
Delta Devices : 1 (10->11)


Update Time : Wed Jun 17 19:24:09 2015
Checksum : de0a23b - correct
Events : 6039833

Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 6
Array State : AAAAAAAAAA. ('A' == active, '.' == missing)



/dev/sdl1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6

Raid Devices : 11

Avail Dev Size : 5860268032 (2794.39 GiB 3000.46 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Used Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
State : clean
Device UUID : a5f4ac69:f6bbac94:60c1b790:db2c223e


Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:28:58 2015
Checksum : c9909fb9 - correct
Events : 6039833

Layout : left-symmetric
Chunk Size : 64K


Device Role : Active device 7
Array State : AAAAAA.AAA. ('A' == active, '.' == missing)


/dev/sdm1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908

Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean

Device UUID : 938d9190:582eecf8:b9157fce:38705df2

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:46:34 2015
Checksum : d2462ecd - correct
Events : 6039833


Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 4
Array State : A.AAA...AA. ('A' == active, '.' == missing)


/dev/sdn1:
Magic : a92b4efc
Version : 1.2

Feature Map : 0x5
Array UUID : 70485ad1:0f5f2362:e8f5489a:577ac908
Name : ubuntu:0
Creation Time : Fri Jan 27 19:20:36 2012
Raid Level : raid6
Raid Devices : 11

Avail Dev Size : 3907024896 (1863.01 GiB 2000.40 GB)
Array Size : 17581612032 (16767.13 GiB 18003.57 GB)
Data Offset : 2048 sectors

Super Offset : 8 sectors
State : clean
Device UUID : 289f68f6:f43d8a40:2203e21c:e6cff371

Internal Bitmap : 2 sectors from superblock
Reshape pos'n : 3196923264 (3048.82 GiB 3273.65 GB)
Delta Devices : 1 (10->11)

Update Time : Wed Jun 17 19:46:34 2015
Checksum : 4db49d1a - correct

Events : 6039833

Layout : left-symmetric
Chunk Size : 64K

Device Role : Active device 8
Array State : A.AAA...AA. ('A' == active, '.' == missing)

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...