Skip to content

Instantly share code, notes, and snippets.

@xameeramir
Last active November 28, 2024 00:28
Show Gist options
  • Save xameeramir/a5cb675fb6a6a64098365e89a239541d to your computer and use it in GitHub Desktop.
Save xameeramir/a5cb675fb6a6a64098365e89a239541d to your computer and use it in GitHub Desktop.
The default nginx configuration file inside /etc/nginx/sites-available/default
# Author: Zameer Ansari
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
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 _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# proxy_pass http://localhost:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
@mrbianchi
Copy link

tyy

@developerJuiceLozzoc
Copy link

i accidentally deleted the whole directory, apt remove and apt install nginx didnt solve it though

@cybernet
Copy link

i accidentally deleted the whole directory, apt remove and apt install nginx didnt solve it though

on debian you have to "purge" the package

$ apt-get remove --purge

When you use the purge flag, it simply removes all config files too

@epkim
Copy link

epkim commented Feb 20, 2020

Thank you!!!

@danielsxavier
Copy link

Thanks!

@arielhasidim
Copy link

Thanks :)

@ChristianJung2
Copy link

Oh man. So many goofs in the world that delete this file on their server. Including me :-) Thank you so much!!!

@sollazzo08
Copy link

When I downloaded nginx for whatever reason it did not come with the sites-available and sites-enabled folder, not sure why. Anyways thanks for this. Does the default file inside sites-available have a file extension?

@johnlinnane
Copy link

johnlinnane commented Jun 4, 2020

My default file does not have a file extension.
Thanks for the gist!

@leregi
Copy link

leregi commented Jun 25, 2020

thanks, you gist helped me

@exp0logy
Copy link

Shit man i thought that said muslims are terroists. Was about to report it 😂

@BartDrown
Copy link

ho so everyone think its normal to have

Personal note: Muslims are not terrorists and I humbly request my engineering community to help end racism. at the very first line without any introduce or any link ? u choked me

I'm sure this is needed for proper configuration

@levihb
Copy link

levihb commented Aug 15, 2021

i now know why this config file outputs an error...

It's a comment, it's not going to output an error because of it. Remove it and try it if you don't believe me.

@Monsluxe
Copy link

Monsluxe commented Aug 22, 2021 via email

@Matgih
Copy link

Matgih commented Aug 25, 2021

Thanks

@robert-kratz
Copy link

Thanks!

@bocarw121
Copy link

Thanks!!

@adamadamsadamson
Copy link

thanx bro

@Wreeper
Copy link

Wreeper commented May 27, 2022

ok but what is that comment at the very top

@gyrusdentatus
Copy link

Is this like the default nginx.conf file just with that agenda of yours ? We don't care if you're muslim, christian or you believe in ancient aliens, nor what's your skin colour. This is open-source. Any creature/being/entity can contribute to the whole cause

@Github-user191
Copy link

@gyrusdentatus It's not the nginx.conf file, this is config file for a virtual host usually found in /etc/nginx/sites-available/default.conf

@bocarwane
Copy link

Hey, check the previous comment

@rajeev-007-glitch
Copy link

rajeev-007-glitch commented Aug 17, 2023

Hello I want to write this content in this file

`

location / {
proxy_pass http://localhost:3000; #whatever port your app runs on
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

`

how can I do that. The solution I came up with is that to remove the whole file and paste the whole content again. This has to be this way because this is going into EC2 user data so this command have to run own there own. So the problem I am facing is that I removed the file but when I want to create the file it has no extension what do I do now. If someone have a solution it will be very helpful and is a better approach then it will also be very helpful.

@gyrusdentatus
Copy link

@gyrusdentatus It's not the nginx.conf file, this is config file for a virtual host usually found in /etc/nginx/sites-available/default.conf

that is exactly what I meant. I thought it was obvious ^^

@G-Guney
Copy link

G-Guney commented Nov 26, 2023

You saved me , Thanks :)

@rmdhfz
Copy link

rmdhfz commented Mar 3, 2024

thank you man!

@BlueBallFatBerg
Copy link

Thanks!

@dsdanielpark
Copy link

Thank you!

@Rhxrrr
Copy link

Rhxrrr commented Jul 12, 2024

goated

@MiranDaniel
Copy link

MiranDaniel commented Aug 24, 2024

I have created a new Gist that will not be edited to promote ideologies (or anything else).

You can find it here, it has both this file and nginx.conf: https://gist.github.com/MiranDaniel/7d0dfe222fbc79c1126899cb51baefb2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment