http { ... server { listen80; server_name myserver.com; # The default root is /usr/share/nginx/www, /usr/share/nginx/html or /var/www/html root /var/www/your_domain/html;
By default, NGINX redefines two header fields in proxied requests, “Host” and “Connection”, and eliminates the header fields whose values are empty strings. “Host” is set to the $proxy_host variable, and “Connection” is set to close.
http { # reuse SSL session parameters to avoid SSL handshakes for parallel and subsequent connections. # or "ssl_session_cache builtin:1000 shared:SSL:10m;" ssl_session_cache shared:SSL:10m; ssl_session_timeout10m; server { listen443 ssl; server_name myproject.com; ssl_certificate /etc/ssl/projectName/projectName.com.pem; ssl_certificate_key /etc/ssl/projectName/projectName.com.key; # Additional SSL configuration (if required) # enabling keepalive connections to send several requests via one connection and the second is to reuse SSL session parameters to avoid SSL handshakes for parallel and subsequent connections. keepalive_timeout70; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; ssl_prefer_server_cipherson;
The ngx_http_v2_module module (1.9.5) provides support for HTTP/2. This module is not built by default, it should be enabled with the --with-http_v2_module configuration parameter.
Adding the following config to the Nginx configuration file. You can verify if the configuration is updated by updating the return status code (e.g. 403 Forbidden, 406 Not Acceptable, 423 Locked) of the /test location and visiting the test URL http://yourDomain/testConfig.
$proxy_host: name and port of a proxied server as specified in the proxy_pass directive;
$proxy_add_x_forwarded_for: the “X-Forwarded-For” client request header field with the $remote_addr variable appended to it, separated by a comma. If the “X-Forwarded-For” field is not present in the client request header, the $proxy_add_x_forwarded_for variable is equal to the $remote_addr variable.
$host: In this order of precedence: host name from the request line, or host name from the “Host” request header field, or the server name matching a request.