Tuesday, March 14, 2023

nginx configuration example for a simple proxy


Build nginx from source code:

$ ./configure --prefix=/path/to/install --with-http_ssl_module --without-http_rewrite_module --with-debug

$ make; make install


Configuration locates at /path/to/install/conf/nginx.conf.

Example of the configuration (for demo purpose only):

server {
  listen  443 ssl;
  server_name localhost;
 
  ssl_certificate  ngcert.pem;
  ssl_certificate  ngprivkey.pem;
 
  # disable HSTS when we are using self-signed certificate
  add_header Strict-Transport-Security  "max-age=0";
 
  ssl_session_cache  shared:SSL:1m;
  ssl_session_timeout  5m;
 
  ssl_ciphers  HIGH:!aNULL:!MD5;  # adjust to remove week ciphers
  ssl_prefer_server_ciphers  on; 

  location / {
    root  html;
    index  index.html;
  }

  location / {
    proxy_pass  https://destination-url/;
  }
}

Run nginx:
$ nginx

   

No comments:

 
Get This <