How to configure Nginx as a reverse proxy

By   10-25-2017 · 1 minute read · 137 words

If you need to configure Nginx as a reverse proxy here is a quick snippet to do so.

This snippet listens on port 443/TLS and redirects users to port 3000 localhost.

If you only want to listen on 443 you can remove the redirect on port 80. Replace the with your own server name.

You also need to replace the ssl_certificate + ssl_certificate_key with your own, you can remove the SSL section if you don’t wish to use SSL.

Also did you notice the http2 parameter? Looks like Nginx supports http2 straight out of the box!

server {
    listen 80;
    listen [::]:80;
    return 301$request_uri;

server {
	listen   443 ssl http2;
        ssl_certificate "/etc/nginx/ssl/public.crt";
        ssl_certificate_key "/etc/nginx/ssl/private.rsa";

	location / {
		proxy_set_header X-Real-IP  $remote_addr;
		proxy_set_header X-Forwarded-For $remote_addr;
		proxy_set_header Host $host;

nginx   reverse-proxy  

comments powered by Disqus