Showing posts with label localhost. Show all posts
Showing posts with label localhost. Show all posts

Saturday, January 27, 2018

Apachectl “service already loaded” when it's not

Leave a Comment

I am trying to learn a bit about the terminal and servers. I am following a course and in this course it states that you can start and stop the server apache (on mac) by using the command:

sudo apachectl start 

But, when I do this, it comes back with a message saying that apache is already functioning. The full message:

/System/Library/LaunchDaemons/org.apache.httpd.plist: service already loaded 

Apache is clearly not running though:

ps aux | grep httpd 

doesn't return any activity.

I expect this is something to do with the fact that the course I am following is for Yosemite and I am running El Capitan. I don't know much about the issue and I am trying to learn, but I can't even follow the course if I can't even start the server.

Can anyone help?

Thanks,

P

edit ---------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>         <key>Disabled</key>         <true/>         <key>Label</key>         <string>org.apache.httpd</string>         <key>EnvironmentVariables</key>         <dict>                 <key>XPC_SERVICES_UNAVAILABLE</key>                 <string>1</string>         </dict>         <key>ProgramArguments</key>         <array>                 <string>/usr/sbin/httpd-wrapper</string>                 <string>-D</string>                 <string>FOREGROUND</string>         </array>         <key>OnDemand</key>         <false/> </dict> </plist> 

2 Answers

Answers 1

Try

apachectl status 

This is probably the best way to check the status of Apache.

Answers 2

Can you try the below

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist sudo apachectl stop sudo apachectl start 
Read More

Sunday, October 29, 2017

Laravel Localhost Using Valet Database Migration Slow Performance

Leave a Comment

[VIRTUAL HOST] Laravel Homestead database migration are so much faster than my [LOCALHOST] Laravel Valet / XAMPP?

Can anyone explain why? Or is there a way to enhance my localhosts speed?

0 Answers

Read More

Friday, September 8, 2017

Access localhost with self signed certificate over https using Ajax

Leave a Comment

I am working on a NodeJS application which runs a server on https://localhost:port and uses a self signed certificate (as no vendor provides a certificate for localhost). I am using AJAX call from my website to hit the locahost and send data to the NodeJs app. My calls are getting blocked due to INSECURE_CONTENT which is expected. I want to know if we have any workarounds for this?

3 Answers

Answers 1

Workaround is to enable it on browser level. This should allow AJAX calls also.

For Chrome

  1. Go to this url in chrome (chrome://flags/#allow-insecure-localhost)
  2. enter image description here
  3. Hit enable.
  4. Then you have to relaunch your chrome browser so changes may affect.

For Firefox

  1. Go to your localhost in firefox. It should show you warning.
  2. Click Advanced
  3. Click Add Exception...
  4. New popup window will appear, click Get Certificate
  5. Verify that checkbox says 'Permanently store this exception'
  6. Click 'Confirm Security Exception'. Refer Image below.

    • enter image description here
    • enter image description here

UPDATE:

As per op's comment, updated answer is below:

(Reply to this comment) For this simple hack is to have a proxy route in your node app. Create route like http://localhost/proxy?yourwebsites_api/getData. In node server proxy route will get GET parameter from your url and hit your website server. And will return same response back. Like you do in c# with HttpWebRequest or HttpClient or in PHP with curl.

Answers 2

Add an entry for local.host 127.0.0.1 to your local hosts file to point the local.host domain to 127.0.0.1 ( on that machine only )
You can then create a self signed certificate for local.host, make sure to use this with your nodejs app, and and add it to the root certificate store on your machine, this will make the browser recognize the certificate.
You need the local.host entry because you need a well formated domain name for your self signed certificate.

You can create a self signed certificate like so:

openssl req -x509 -nodes -days 1000 -subj '/C=US/ST=CA/L=MV/CN=local.host'  -newkey rsa:2048 -keyout local.host.key -out local.host.crt 

On osx the hosts file is located on /etc/hosts on windows it's at c:\windows\system32\drivers\etc\hosts

Here is how you can add your certificate to the root certificate store:

OSX:
https://pubs.vmware.com/flex-1/index.jsp?topic=%2Fcom.vmware.horizon.flex.admin.doc%2FGUID-9201A917-D476-40EF-B1F4-BBF14AB83D94.html

Windows:
http://www.thewindowsclub.com/manage-trusted-root-certificates-windows

Update:

Op pointed out by OP the app would be installed on a consumer desktop.

You could potentially generate a certificate for a myapp.mydomain.com, and point that to 127.0.0.1 after you require the certificate. This does not require you to add a certificate to to the root store. However, this will still require you to ship the private key with the app, which compromises the certificate for all users, it will also be painful to update the certificate. This is not a good solution.

You can generate a unique certificate during installation and install it in the root store. This also compromises the certificate, but only to the specific user. This reduces the attack vector, as the certificate it self is only supposed to protect the user, this is actually also how charlesproxy works.

Answers 3

The very easiest way to do this is to get an ngrok account. Ngrok uses wildcardcerts so you can run your server on your local machine but your urls start https://mycompany.ngrok.io

In addition to being more like a real server (urls can ignore the port) the ngrok control panel lets your replay messages (e.g. a form post breaks something server side; fix your server side code and re-play from the ngrok control panel so you don't have to fill in the form again)

Ngrok is also great if you want to be able to share your work in progress. The tunnels that ngrok creates are open to the public (unless you password protect them)

It's $60 per year for your own domain. Free if you want to use random domains like https://ba615d46.ngrok.io

Read More

Saturday, May 20, 2017

Subject Alternative Name Missing & ERR_SSL_VERSION_OR_CIPHER_MISMATCH

Leave a Comment

I followed this answer to make https://localhost:3000/ work in Chrome & Mac. Today, it suddenly does not work anymore.

https://localhost:3000 gives Not Secure:

Subject Alternative Name Missing The certificate for this site does not contain a Subject Alternative Name extension containing a domain name or IP address. 

I re-trusted this certificate by following the previous steps, it did not help. Then, I saw this answer, I need to remake ssl keys.

I make v3.ext:

authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names  [alt_names] DNS.1 = localhost 

Then,

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -sha256 -extfile v3.ext 

However, it returns

unknown option -extfile req [options] <infile >outfile where options  are  -inform arg    input format - DER or PEM  -outform arg   output format - DER or PEM  ... ... 

Does anyone know what's wrong with my openssl command?

Otherwise, does anyone know how to fix this Subject Alternative Name Missing or NET::ERR_CERT_COMMON_NAME_INVALID error?

enter image description here

Edit 1: I tried to follow this answer and here is my example-com.conf:

[ req ] default_bits        = 2048 default_keyfile     = server-key.pem distinguished_name  = subject req_extensions      = req_ext x509_extensions     = x509_ext string_mask         = utf8only  # The Subject DN can be formed using X501 or RFC 4514 (see RFC 4519 for a description). #   Its sort of a mashup. For example, RFC 4514 does not provide emailAddress. [ subject ] countryName         = Country Name (2 letter code) countryName_default     = US  stateOrProvinceName     = State or Province Name (full name) stateOrProvinceName_default = NY  localityName            = Locality Name (eg, city) localityName_default        = New York  organizationName         = Organization Name (eg, company) organizationName_default    = Example, LLC  # Use a friendly name here because its presented to the user. The server's DNS #   names are placed in Subject Alternate Names. Plus, DNS names here is deprecated #   by both IETF and CA/Browser Forums. If you place a DNS name here, then you #   must include the DNS name in the SAN too (otherwise, Chrome and others that #   strictly follow the CA/Browser Baseline Requirements will fail). commonName          = Common Name (e.g. server FQDN or YOUR name) commonName_default      = Example Company  emailAddress            = Email Address emailAddress_default        = test@example.com  # Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ... [ x509_ext ]  subjectKeyIdentifier        = hash authorityKeyIdentifier  = keyid,issuer  # You only need digitalSignature below. *If* you don't allow #   RSA Key transport (i.e., you use ephemeral cipher suites), then #   omit keyEncipherment because that's key transport. basicConstraints        = CA:FALSE keyUsage            = digitalSignature, keyEncipherment subjectAltName          = @alternate_names nsComment           = "OpenSSL Generated Certificate"  # RFC 5280, Section 4.2.1.12 makes EKU optional #   CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused #   In either case, you probably only need serverAuth. # extendedKeyUsage  = serverAuth, clientAuth  # Section req_ext is used when generating a certificate signing request. I.e., openssl req ... [ req_ext ]  subjectKeyIdentifier        = hash  basicConstraints        = CA:FALSE keyUsage            = digitalSignature, keyEncipherment subjectAltName          = @alternate_names nsComment           = "OpenSSL Generated Certificate"  # RFC 5280, Section 4.2.1.12 makes EKU optional #   CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused #   In either case, you probably only need serverAuth. # extendedKeyUsage  = serverAuth, clientAuth  [ alternate_names ]  DNS.1       = localhost  # IPv4 localhost IP.1       = 127.0.0.1  # IPv6 localhost IP.2     = ::1 

Then, I did

openssl req -config example-com.conf -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout example-com.key.pem -days 365 -out example-com.cert.pem 

Reopen https://localhost:3000 in Chrome gives me

localhost uses an unsupported protocol. ERR_SSL_VERSION_OR_CIPHER_MISMATCH 

Could anyone help?

1 Answers

Answers 1

I suggest the following solution: create self-signed CA certificate and the web server certificate signed by this CA. When you install this small chain to your web server it will work with Chrome.

Create configuration file for your CA MyCompanyCA.cnf with contents (you can change it to your needs):

[ req ] distinguished_name  = req_distinguished_name x509_extensions     = root_ca  [ req_distinguished_name ] countryName             = Country Name (2 letter code) countryName_min         = 2 countryName_max         = 2 stateOrProvinceName     = State or Province Name (full name) localityName            = Locality Name (eg, city) 0.organizationName      = Organization Name (eg, company) organizationalUnitName  = Organizational Unit Name (eg, section) commonName              = Common Name (eg, fully qualified host name) commonName_max          = 64 emailAddress            = Email Address emailAddress_max        = 64  [ root_ca ] basicConstraints            = critical, CA:true 

Create the extensions configuration file MyCompanyLocalhost.ext for your web server certificate:

subjectAltName = @alt_names extendedKeyUsage = serverAuth  [alt_names] DNS.1   = localhost DNS.2   = mypc.mycompany.com 

Then execute the following commands:

openssl req -x509 -newkey rsa:2048 -out MyCompanyCA.cer -outform PEM -keyout MyCompanyCA.pvk -days 10000 -verbose -config MyCompanyCA.cnf -nodes -sha256 -subj "/CN=MyCompany CA"  openssl req -newkey rsa:2048 -keyout MyCompanyLocalhost.pvk -out MyCompanyLocalhost.req -subj /CN=localhost -sha256 -nodes openssl x509 -req -CA MyCompanyCA.cer -CAkey MyCompanyCA.pvk -in MyCompanyLocalhost.req -out MyCompanyLocalhost.cer -days 10000 -extfile MyCompanyLocalhost.ext -sha256 -set_serial 0x1111 

As result you will get MyCompanyCA.cer, MyCompanyLocalhost.cer and MyCompanyLocalhost.pvk files that you can install to the web server.

How to check that it works with Chrome before installing certificates to the web server. Execute the following command on your local PC to run web server simulator:

openssl s_server -accept 15000 -cert MyCompanyLocalhost.cer -key MyCompanyLocalhost.pvk -CAfile MyCompanyCA.cer -WWW 

Then you can access this page at https://localhost:15000/ You will see an error that MyCompanyLocalhost.cer is not trusted, if you want to eliminate this error also - then install MyCompanyCA.cer to the certificate trusted list of your OS.

Read More

Saturday, April 9, 2016

Visual studio 2015 waiting for localhost after first load for debug

Leave a Comment

I have been struggling with debugging on Visual studio 2015 Community Update 1 and 2. After first debug session everything works correctly. But when I make changes during the debug and I refresh the website, it start waiting on localhost forever. This also happens if I stop debugging, make changes and then launch debug session again. This happens 95% of the time. I have searched stackoverflow and googled for similiar problems and none of the answer others has proposed has not fixed this problem. Only what works is to restart VS again after first debug.

What I have tried so far:

  1. Uninstalled Visual Studio 2015 and installed back.
  2. Cleaned Temp folder(that what is used with IIS Express)
  3. Reinstalled IIS 10
  4. Launched VS as administator-
  5. ...... Created whole new solution with 3 projects and copy pasted all code to new solution - hoping this could fix any path problems.
  6. Created new TFS project and linked there
  7. Disabled Firewall temporarily
  8. Just released Update 2 for VS 2015 Community didn't fix also.
  9. Cleared symblos also loaded symbols from microsoft servers.
  10. Disabled Browser Link

I'm running out of patience and ideas how to fix this annoying problem. My guess is something goes wrong after first load of files and then when VS try to copy files back to temporary folder, it can't or something stops working. Anyone got ideas?

2 Answers

Answers 1

Here are new things for you to try, I believe one of them will solve ur issue. I am listing from most I believed to least:

  • Try to create new app pool and assign your website to it. Make sure the user authentication for the new app pool is provided correctly.

  • Set the connection timeout to something reasonable like 15 seconds in the web.config.

  • Try using local IP address instead localhost Disable all the antivirus programs in addition to firewalls, if you are using. Check for the blocked ports on firewall and change the dynamic ports of application if any to fixed trustable ports.

  • Someone says on the internet:"the problem might be that downloading files from torrent and your database is on a different server"

  • Someone on internet also says: "I deleted the .suo file and this fixed the issue."

This website might help also: http://dustyreagan.com/localhost-doesnt-work-cant-debug-your/

EDIT: Please check the solutions on this websites: https://marcclifton.wordpress.com/2014/05/18/page-not-rendering-with-iis-express-in-firefox-or-chrome-waiting-for-localhost/

http://codetunnel.io/how-to-debug-your-aspnet-projects-running-under-iis/

Answers 2

Sometimes it helps to:

taskkill /f /im:iisexpress.exe rmdir /s /q [path to your solution]\bin rmdir /s /q [path to your solution]\obj taskkill /f /im:conhost.exe 

I've that in a wee batch file that I run before trying to deploy / debug, particularly when I'm switching between Debug and Release modes. Basically, clearing out the objects and killing off the iis express and console host give you a fresh start.

Read More