Skip to content

Using nginx as proxy to NodeJS server running on localhost #26

@niloy

Description

@niloy

Redirects all traffic coming to example.com to localhost:5555. Also redirects all http to https. Below is the nginx conf file.

server {
    listen 80;
    listen 443 ssl;

    server_name example.com;

    ssl_certificate /etc/ssl/ssl.crt;
    ssl_certificate_key /etc/ssl/ssl.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    ssl_prefer_server_ciphers on;

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

    if ($ssl_protocol = "") {
        return 301 https://example.com$request_uri;
    }
}

If SSL is not required, the conf is even simpler, given below. Remove server_name if its the default server.

server {
    listen 80;
    server_name example.com;

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions