Title: nginx
Last modified: August 20, 2016

---

# nginx

 *  Resolved [popac](https://wordpress.org/support/users/popac/)
 * (@popac)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/nginx-4/)
 * Hi,
    I just checked, plugin don’t work with nginx installed on Apache server.
   Can you do something about it ? In my humble knowledge I think that .htaccess
   should be modified. When working directly with Apache, plugin behaves well, **
   good work !**
 * [http://wordpress.org/extend/plugins/imaguard/](http://wordpress.org/extend/plugins/imaguard/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [imaguard](https://wordpress.org/support/users/imaguard/)
 * (@imaguard)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464852)
 * Hi,
 * The plugin is written for apache servers, and the htaccess files will have to
   be converted to work on Nginx servers.
 * You should be able to just copy the file into a converter like this
 * [http://winginx.com/htaccess](http://winginx.com/htaccess)
 * And paste it into you nginx configuration instructions (nginx doesn’t use htaccess
   files at all).
 * I have NOT tested this, so don’t kill me if it screws up something 🙂
 *  Plugin Author [imaguard](https://wordpress.org/support/users/imaguard/)
 * (@imaguard)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464888)
 * Marking this topic as resolved, but just let us know if you still have any questions
   and we will assist as best we can.
 *  Thread Starter [popac](https://wordpress.org/support/users/popac/)
 * (@popac)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464899)
 * Hi, I’m back with first results…
 * for converting .htaccess to nginx I use
 * [http://www.anilcetin.com/](http://www.anilcetin.com/)
 * This converter is much better.
 * After converting htacces file I get this:
 *     ```
       if ($http_referer !~* "^http://(.+.)?websitename.com"){
       	set $rule_0 1$rule_0;
       }
       if ($rule_0 = "1"){
       	rewrite ^/(.*).(jpg|png|jpeg|gif)$ /show-image/?img=/$1.$2 permanent;
       }
       ```
   
 * This code need to enter to **vhost.conf** (if you have multiple websites that
   use nginx or **nginx.conf** if you have all website settings in one file ( I 
   hope nginx users will understand).
 * Then need to restart nginx service/server:
    **nginx -s stop** and then start 
   again **nginx**
 * Firstly I configured plugin to work with option “Show text over image”
    and all
   worked ok, after that I try solution with redirection and also have good result,
   just like you write for plugin.
 * Need to say that plugin now working much faster compared to the previous versions.
 * Remained to see how G search engine responds to 301/302 redirection and how it
   will work in future (indexing new content, status of old indexed images, position
   etc). I will write here my results.
 *  Thread Starter [popac](https://wordpress.org/support/users/popac/)
 * (@popac)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464901)
 * I have problem with Dedicated Server overload
    Error message:
 * > WordPress database error MySQL server has gone away for query SELECT option_value
   > FROM wpdatabase_options WHERE option_name = ‘pt_body_color’ LIMIT 1 made by
   > require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’),
   > include(‘/themes/mytheme1/404.php’), get_header, locate_template, load_template,
   > require_once(‘/themes/mytheme1/header.php’), get_settings, get_option
 * etc etc…
 * error dump rapidly increasing
 *  Plugin Author [imaguard](https://wordpress.org/support/users/imaguard/)
 * (@imaguard)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464902)
 * First of all: thanks for sharing your experiences with implementing Imaguard 
   on a nginx server!
 * As for your server errors: This is very odd. The error doesn’t seem to be related
   to Imaguard. I have no experience with Nginx servers. Is it possible to trace
   it back to a page called by the user? F ex if the page that caused the error 
   was originally f ex yourblog.com/show-image ?
 *  Thread Starter [popac](https://wordpress.org/support/users/popac/)
 * (@popac)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464903)
 * Interesting is that error going from file to file :
 * i wrote here: WHERE option_name = ‘pt_body_color’
 * but next errors are:
 * WHERE option_name = ‘jwplayermodule_uninstalled’
    WHERE option_name = ‘theme_switched’
   WHERE post_name IN (‘show-image’).. etc etc…
 * I will try again later, now is not good time for testing on live website 🙂
 *  Plugin Author [imaguard](https://wordpress.org/support/users/imaguard/)
 * (@imaguard)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464904)
 * No, that’s probably not a good idea!
 * Oddly enough the queries giving the error seems completely straight forward:
 * `SELECT option_value FROM wpdatabase_options WHERE option_name = 'pt_body_color'
   LIMIT 1`
 * I presume if you run that query manually (f ex with phpmyadmin) it would perform
   normally. If so there must be an access problem somewhere.
 *  [beakman](https://wordpress.org/support/users/beakman/)
 * (@beakman)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464984)
 * Hello there!
    I don’t know if I’m doing it correctly. I’m using **NGINX** too.
   So I edited my vhost config file located in **‘/etc/nginx/sites-enabled/wordpress’**
   this way:
 *     ```
       location / {
               try_files $uri $uri/ /index.php?$args;
               # Imaguard:
               if ($http_referer !~* "^http://(.+.)?my-domain.com"){
                 set $rule_0 1$rule_0;
               }
               if ($rule_0 = "1"){
                 rewrite ^/(.*).(jpg|png|jpeg|gif)$ /show-image/?img=/$1$
               }
           }
       ```
   
 * but I’m not seeing any watermarking in the Google Images search results. When
   I point my browser to **‘[http://www.my-domain.com/wp-content/uploads/2013/05/images.jpg?test&#8217](http://www.my-domain.com/wp-content/uploads/2013/05/images.jpg?test&#8217);**
   I get an 404 error, what is supposed, right? Also, when I click on a result in
   the Google Images search, it redirects me to the post where the image appears.
   So I think that everything is working properly but the watermarking. Any clue
   of what I’m missing?

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘nginx’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/imaguard.svg)
 * [Imaguard](https://wordpress.org/plugins/imaguard/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/imaguard/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/imaguard/)
 * [Active Topics](https://wordpress.org/support/plugin/imaguard/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/imaguard/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/imaguard/reviews/)

## Tags

 * [nginx](https://wordpress.org/support/topic-tag/nginx/)

 * 8 replies
 * 3 participants
 * Last reply from: [beakman](https://wordpress.org/support/users/beakman/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/nginx-4/#post-3464984)
 * Status: resolved