Skip to content

Instantly share code, notes, and snippets.

@IShubhamj
Last active February 25, 2021 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IShubhamj/b61a14a5e0b5dd9d7cde7a6b9753321e to your computer and use it in GitHub Desktop.
Save IShubhamj/b61a14a5e0b5dd9d7cde7a6b9753321e to your computer and use it in GitHub Desktop.
Nginx reverse proxy configuration
map $sent_http_content_type $expires {
default off;
text/html epoch; #means no cache, as it is not a static page
text/css max;
application/javascript max;
application/woff2 max;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name your_domain.com www.your_domain.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
#listen 443 ssl http2 default_server;
listen 443 ssl default_server;
#listen [::]:443 ssl http2 default_server;
listen [::]:443 ssl default_server;
expires $expires;
server_name your_domain.com www.your_domain.com; // your domain will goes here if you want to use www then add
// '@' record in your DNS record.
location / {
proxy_pass http://localhost:9090/; // my host for docker is 9090 change it if you configured different port
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment