Last active
February 25, 2021 09:45
-
-
Save IShubhamj/b61a14a5e0b5dd9d7cde7a6b9753321e to your computer and use it in GitHub Desktop.
Nginx reverse proxy configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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