Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

The future of AI-driven development. Join the discussion around insights on low code's and AI's roles in building mission-critical apps.

Has GenAI transformed how you work? Or has the hype cycle played out? Tell us your thoughts on its impact inn your organization.

DevEx Roundtable: Join the discussion about the evolving needs of the developer from streamlined workflows to infrastructures investments.

Installing NGINX and HTTP/2 in Your Local Development Environment

How can you get NGINX and HTTP/2 working together in your local development environment? Read this post to find out how.

By  · Tutorial
Comment (0)
Save
8.7K Views

this article has been written in accompany with another article, best practice for http2 front-end deployments — part two . it will make use of homebrew on mac os x in order to install nginx with http/2 support. so, fire up a terminal and let's get started.

1. install homebrew

if you don't already have homebrew , then you should install it first. copy and paste the command below:

2. install nginx

first, let's update the list of homebrew packages:

now, let's compile and install nginx with http2:

next, let's double check we have the right version of nginx. also, it's worth noting that http/2 will only work with version 1.9.5 and above.

you should see nginx version: nginx/1.10.1 at the time of writing. please make sure it's above 1.9.5.

now, let's check that nginx is working. make sure that port 8080 is available. we're using sudo, so you may be prompted for your password:

you should now see the welcome to nginx! page. for the moment, we can stop nginx by using:

3. configure nginx to use ssl and http/2

next, we need to make some changes to nginx.conf . use your favorite text editor to open nginx.conf. in the example below, we're using texmate.

the changes that we need to make are shown below in the server {} block:

4. generate an ssl certificate

http/2 requires a secure connection over tls (the new name for ssl). before we can use https, we first need to generate an ssl certificate:

this is a self-signed certificate, meaning that you'll see a browser security warning when using it. you can add a security exception for your local development domain.

5. restart nginx

now you can (or should be able to) hit https://localhost/ , and nginx should proxy pass to your local development server.

to check that http/2 is working, you can open the web inspector in your browser and check the network page. in the protocol column, you should now see h2 or http2 next to each request.

Published at DZone with permission of Brent Graham. See the original article here.

Opinions expressed by DZone contributors are their own.


Comments