created by Aha00aAha00a at 2017-08-17
last modified by Aha00aAha00a at 2026-09-10
revision: 3

nginx Tls for localhost

1. Create a Self-signed Certificate (valid for an year)

openssl req -new -x509 -keyout localhost.key -out localhost.pem -days 365 -nodes

2. nginx config


# ...
# some other settings go on...
# ...

http {

    # ...
    # some other settings go on...
    # ...

    server {
        listen       8443 ssl;
        server_name  localhost;

        ssl_certificate      /path/to/localhost.pem;  # TODO: fix location
        ssl_certificate_key  /path/to/localhost.key;  # TODO: fix location

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / { proxy_pass http://localhost:9000; }
    }
}

3. Launch Chrome with ignore option

  • macOS
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome  --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://localhost:8443
  • Linux
    google-chrome --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://localhost:8443
  • Windows

5. See Also

5.2. Adjacent Pages

≤ 32
all
1.0x
1.0x
80
-120
ON
0/0
0/0
0.00
0
0 / 0
1.00x