1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SEO Urls - Nginx - Help

Discussion in 'Troubleshooting and Problems' started by Bigstack, Apr 15, 2013.

  1. Bigstack

    Bigstack Member

    Ok So i have spent the better part of a day and a half trying to figure out how to setup the nginx config for this. I am coming from a server that had Cpanel + nginx and everything worked just fine. My new server I just put virtual min on and I belive the php is in fastcgi mode not DSO like before... The only way to get my site to work right now is to turn off friendly URLs but I have hard links to the others ones over the net.

    Here is mynginx.conf (added note it also pulles in /etc/nginx/conf.d/default.conf) I can post that if necessary.

    My site root is:

    user  nginx;
    worker_processes  2;
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    events {
        worker_connections  1024;
    http {
        include      /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        #tcp_nopush    on;
        keepalive_timeout  65;
        #gzip  on;
        include /etc/nginx/conf.d/*.conf;
        server_names_hash_bucket_size 128;
        server {
            server_name websitehere.com www.websitehere.com;
            root /home/websitehere/public_html;
            index index.html index.htm index.php;
            access_log /var/log/virtualmin/websitehere.com_access_log;
            error_log /var/log/virtualmin/websitehere.com_error_log;
            fastcgi_param GATEWAY_INTERFACE CGI/1.1;
            fastcgi_param SERVER_SOFTWARE nginx;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_param SCRIPT_FILENAME /home/websitehere/public_html$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_param REQUEST_URI $request_uri;
            fastcgi_param DOCUMENT_URI $document_uri;
            fastcgi_param DOCUMENT_ROOT /home/websitehere/public_html;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param REMOTE_ADDR $remote_addr;
            fastcgi_param REMOTE_PORT $remote_port;
            fastcgi_param SERVER_ADDR $server_addr;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_NAME $server_name;
            location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/php-nginx/136598955615441.sock/socket;
    Any help greatly appreciated im stuck.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Bigstack

    Bigstack Member

    I have been there. I have put them into the file but it errors. I think there is an issue with how virtual-min setup the nginx for my site. The config above is what is there by default.
  4. Tracy Perry

    Tracy Perry Well-Known Member

    Here is my forums nginx config file - it's working and friendly URLS are enabled. You will need to edit the paths to reflect your setup. The allow: xxx.xxx.xxx.xxx will need to be changed to your IP if you use Munin - it was the only reliable way I could get some of the plugins to work that needed stub access. If you don't need stub access then you can remove that segment.

    server {
    server_name twowheeldemon.com;
    server {
        listen 80;
        server_name www.ride-texas.org ride-texas.org;
        return 301 http://twowheeldemon.com$uri;
    server {
        listen 80;
        server_name www.twowheeldemon.com;
        return 301 http://twowheeldemon.com$uri;
    server {
        listen 80 default;
            server_name _;
                rewrite ^ $scheme://twowheeldemon.com;
    server {
        listen  80;}
    server {
        server_name twowheeldemon.com;
    location /nginx_status {
                    stub_status on;
                    access_log  off;
                    allow xxx.xxx.xxx.xxx;
                    allow xxx.xxx.xxx.xxx;
                    deny all;
        error_log /var/log/nginx/twd-error.log warn;
        access_log /var/log/nginx/twd-access.log;
        root /var/www/twowheel;
    #  Main Site Related
    location /var/www/twowheel/admin.php {
    auth_basic "Restricted";
    auth_basic_user_file /etc/phpmyadmin/my.pass.word;
    # Used for the SiteMaps add-on
        rewrite /(robots.txt)$ /robots.php last;
    location /internal_data/ {
        location /library/ {
        location / {
                #This sends everything through index.php and keeps the appended
                #query string intact.
                try_files $uri $uri/ /index.php?$uri&$args;
                index index.html index.htm index.php;
        #gzip it, gzip it good
          gzip                    on;
          gzip_http_version      1.1;
          gzip_vary              on;
          gzip_min_length        1100;
          gzip_buffers            64 8k;
          gzip_comp_level        2;
          gzip_proxied            any;
          gzip_types          text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
          gzip_disable "MSIE [1-6]\.(?!.*SV1)";
          # use fastcgi for all php files
            location ~ \.php$ {
            # Zero-day exploit defense.
            # http://forum.nginx.org/read.php?2,88845,page=3
            try_files $uri /index.php =404;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            #add some expires
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 1y;
            log_not_found off;
            # deny access to apache .htaccess files
            location ~ /\.ht
            deny all;
    maszd and Jake Bunce like this.

Share This Page