As title, is there any way to host google pagespeed insights on my own server instead of using google api to run a test?
Thanks
Yes, but with a few caveats.
First off, the core of PageSpeed is open-source, and so are the browser extensions (Chrome, FF), which provide built-in optimization recommendations. Given the projects above, you already have all the necessary code available to run it yourself.
PageSpeed also ships with a har_to_pagespeed tool, which you can use to to generate a list of recommendations. Check out this blog post from Steve Souders. Link to his online tool.
To generate a har file you'll need a separate process / browser driver - there are a few open-source tools available that can do this. Check out phantom.js.
Finally, the above has a small caveat. har_to_pagespeed
won't give you the exact same results as a browser extension, because the browser extensions analyze the DOM as well and make some recommendations based on that. This data is not available within the HAR format.