Sharing my nginx config

User avatar
Rag3Rac3r
Bear Rating Trainee
Bear Rating Trainee
Posts: 2
Joined: 20 Mar 2013, 17:45
Location: Sweden

Sharing my nginx config

Postby Rag3Rac3r » 23 Mar 2013, 21:01

Hi all, this is my first post :)

I thought i would share my nginx configuration with any one that might struggle with it. The config makes a honest attempt to block out as much as possible that should not be world accessible. However, i guess that i have some more digging to do before i could consider it fully finished.

Code: Select all

server {
    listen 127.0.0.1:12345;
    server_name domain.example.tld;

    ssl_certificate /path/to/nginx/ssl/*.crt;
    ssl_certificate_key /path/to/nginx/ssl/*.key;

    access_log /path/to/your/access.log main;

    index index.php;
    root /path/to/doc/root;

    # Restrict access to everything
    location / {
        deny all;
    }

    location = / { } # Needed for index.* to work
    location ~* \.(txt|css|js|png|gif|ico|jpg|svg)$ { } # Allow these file endings

    # Lock out access to some folders that contains files that should not be world readable (not fully tested)
    location ~* (include/|lock/|utils/|locale/|classes/*) {
        deny all;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /path/to/your/error/pages;
    }

    location ~* \.php$ {
        fastcgi_pass 127.0.0.1:12345;  # IP/port that php-fcgi process listens on
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /path/to/doc/root/$fastcgi_script_name;
        include fastcgi_params;
    }

alvanorichie
Bear Rating Trainee
Bear Rating Trainee
Posts: 5
Joined: 21 Mar 2013, 14:01
Location: Tampa Bay,FL

Re: Sharing my nginx config

Postby alvanorichie » 26 Mar 2013, 15:28

In my nginx conf file, I have :

Code: Select all

  listen       80;
  server_name  $hostname;


however if I do netstat I see that it is listening on 0.0.0.0:80

what I want to happen, is the nginx to listen to $hostname:80 , is there a way to configure it to do that?

shabble
Bear Rating Trainee
Bear Rating Trainee
Posts: 33
Joined: 18 Mar 2013, 23:40

Re: Sharing my nginx config

Postby shabble » 26 Mar 2013, 16:04

alvanorichie wrote:what I want to happen, is the nginx to listen to $hostname:80 , is there a way to configure it to do that?

listen $hostname:80


Return to “Everything else”

Who is online

Users browsing this forum: No registered users and 1 guest