Quantcast
Channel: Nginx Forum - How to...
Viewing all 2931 articles
Browse latest View live

beginner's question: Site Configuration, same Port, 2 Locations (11 replies)

$
0
0
Hi,

i'm just new to nginx and need help.

I wan't to activate two sites, both with listen 443 and the same certificate:

1.) Owncloud
2.) FHEM with Reverse Proxy port 8083

They're both installed on the same maschine, but i can't ghet both to work, just if i change the port for one of the config files.

owncloud-config file:
-----

upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}

server {
listen 80;
server_name test;
# enforce https
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name test;

ssl_certificate /etc/ssl/nginx/test.cert;
ssl_certificate_key /etc/ssl/nginx/test.key;

# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";

# Path to the root of your installation
root /opt/;
# set max upload size
client_max_body_size 16G;
fastcgi_buffers 64 4K;

# Disable gzip to avoid the removal of the ETag header
gzip off;

# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;


index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;

location /fhem {
proxy_pass http://localhost:8083/fhem;
proxy_redirect off;
proxy_buffering off;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
access_log /var/log/nginx/fhem.access.log;
error_log /var/log/nginx/fhem.error.log;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}


location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
deny all;
}

location /owncloud/ {
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

rewrite ^/(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ /index.php;
}

location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
}

# Adding the cache control header for js and css files
location ~* \.(?:css|js)$ {
add_header Cache-Control "public, max-age=7200";
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
# Optional: Don't log access to assets
access_log off;
}

# Optional: Don't log access to other assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
access_log off;
}

}



fhem config file:
-----
server {
listen 443 ssl;
server_name test;

ssl_certificate /etc/ssl/nginx/test.cert;
ssl_certificate_key /etc/ssl/nginx/test.key;

access_log /var/log/nginx/fhem.access.log;
error_log /var/log/nginx/fhem.error.log;

location /fhem {
proxy_pass http://localhost:8083/fhem;
proxy_redirect off;
proxy_buffering off;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}

----

Can somebody please tell me how or why it can't be done,

thank you very much.

Regards,

Klaus

Yii2 *.conf for frontend, backend and api (!) (1 reply)

$
0
0
Frontend (/) work succesfully.
Backend (/admin) work succesfully.
Api (/api) returned 404.

My nginx configurations for host (Windows 7):

#
# Yii2 Advensed template configs
#
server {
listen 5000;
server_name localhost;
root html/gophp;

access_log off;
error_log logs/goshop.error.log;

charset utf-8;
client_max_body_size 100M;

location / {
root html/gophp/frontend/web;
try_files $uri /frontend/web/index.php?$args;
}

location ~* \.php$ {
try_files $uri /frontend/web$uri =404;
fastcgi_pass 127.0.0.1:9123;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* \.(htaccess|htpasswd|svn|git) {
deny all;
}

location /admin {
alias html/gophp/backend/web;
try_files $uri /backend/web/index.php?$args;

location ~* ^/admin/(.+\.php)$ {
try_files $uri /backend/web/$1?$args;
}
}

location /api {
alias html/gophp/api/web;
try_files $uri /api/web/index.php?$args;

location ~* ^/api/(.+\.php)$ {
try_files $uri /api/web/$1?$args;
}
}
}

Why /api is not working?
Help me, please...

Get file with DAV instead of execution result (no replies)

$
0
0
HI,

How do I prevent file execution when using DAV?
I need to get the source of a PERL file for remote edition, but NGINX only serves the result of the execution through FCGI. I have attached a small example for demonstration with pertinent data only.

The site runs well, I just want to be able to edit the files.

Looking into the log files, it is obvious that the perl handler is called, even though DAV should serve the file source only.

2015/11/12 19:55:40 [error] 29735#29735: *56776 FastCGI sent in stderr: "Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?" while reading response header from upstream, client: 192.168.0.67, server: local11, request: "GET /reports.pl HTTP/1.0", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:"

I do not get error messages when using the site, so the fcgi and upstream are well configured.
Thanks,

Yves

NginX works with an index.php file, but not with the other (12 replies)

$
0
0
Hello Guys,

I have been given a task to migrate a very old website to a new server. The old server was using PHP 5.4, the new one is using PHP 5.6, but this is not the issue I think. My main problem is, if I set up the NginX config nicely the browser gives me an internal server error code 500. Not NginX, the browser doesn't even gets there and the logs do not log anything.
HOWEVER: If I change only the root path to somewhere inside the original root and I create a PHPInfo file as index.php, then that IS displayed in the browser without any errors.
How come the browser can see the "website" correctly if it is set to the phpinfo index.php, but can't even get to NginX if it points to the original index.php?

Here is the NginX conf file with some details outlined:
http://pastebin.com/3MJC79q3

NGinx Load Balancer / Apache Backend / HTTP 499 (1 reply)

$
0
0
Hi All,

I have NGinx configured as a Load Balancer with Apache servers at the backend serving a PHP application. We use 'Pingdom.com' for external application monitoring. I noticed several "outages" rarely lasting more than the minute between checks.

I added some additional logging as detailed here: https://www.nginx.com/resources/admin-guide/logging-and-monitoring

--nginx access log
108.62.115.226 - - [13/Nov/2015:20:11:03 +0000] "GET //login/index.php HTTP/1.1" 499 0 "-" "Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)"rt=30.031 uht="-" urt="-"

On checking each of the Apache backend I found:
108.62.115.226 - - [13/Nov/2015:20:10:33 +0000] "GET //login/index.php HTTP/1.0" 200 6968

The interesting part here is that the Apache backend log entry is 30 seconds *before* the NGinx log entry. I guess the order of the process is
- Nginx passes request to backend but doesn't log it
- Apache deals with it and responds
- However NGinx doesn't receive it
- Pingdom closes the connection which results in the HTTP 499 which is logged in the NGinx log.

The clocks are in sync via NTP and I've manually verified they're not out of time with a `date` on the CLI.

What I'd like to gain some insight into is why NGinx doesn't appear to receive the response. It appears that Apache is responding fine and many of the help articles I've read seems to indicate that the backend is usally at fault but this doesn't appear to be the case here.

Any help would be greatly appreciated.

Thanks!

How to find reason for NGINX redirect (1 reply)

$
0
0
We have an Ubuntu server image that was moved to a different host. ProjectSend is installed on the image.

When the image is running on the original host, everything works. When it's copied to a new host, NGINX redirects any requests back to the old host.

I can't see any explicit redirects in NGINX configuration or .htaccess. I've grepped the NGINX configuration directory, and the ProjectSend directory, for any references to the domain where the redirects are sent but I don't see anything.

Is it possible to enable some debug output to provide information on why NGINX is redirecting? I see the 302 in access.log but it doesn't tell me why this is happening.

nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/includes/error-pages.conf:7 (3 replies)

$
0
0
Hi I got this error:

nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/includes/error-pages.conf:7

My /error-pages.conf:

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
error_page 404 = @fallback;

location @fallback {
proxy_pass https://aebian.org/404;
}





## Whats causing this?

sub_filter and proxy_pass (no replies)

$
0
0
Hi,
I'm using Nginx 1.8 and trying to add a sub_filter but It fails to work (I don't see the substitution happenning).


location ~* \.(appcache|manifest)$ {
expires -1;
rewrite ^(/v[0-9]+/.*)$ /app_ver$1 break;
rewrite ^(?!/v[0-9]+/)(.*)$ /app$1 break;
proxy_set_header Accept-Encoding "";
sub_filter 'CACHE' 'CACHE22';
sub_filter_once on;
proxy_pass http://static.dev.capriza.com.s3.amazonaws.com:80 ;
}


You can see below that the sub_module is there:

root#2>&1 nginx -V | tr -- - '\n' | grep _module
http_ssl_module
http_realip_module
http_addition_module
http_sub_module
http_dav_module
http_flv_module
http_mp4_module
http_gunzip_module
http_gzip_static_module
http_random_index_module
http_secure_link_module
http_stub_status_module
http_auth_request_module
mail_ssl_module
http_spdy_module

Any idea what may be wrong here?

Tx,
Yuval

remove nginx from https response header (1 reply)

$
0
0
nginx 1.9.5

I know how to remove or change the "nginx" string in the server field of the response header.
For http traffic modify the ../src/http/ngx_http_header_filter_module.c

But https (http2) traffic seems to be else where, anyone happen to know where? I've looked around, thought I've found once or twice - turned out nope.

Thanks

setting expires with multiple values for same object (no replies)

$
0
0
Hi

I am trying set a value for expire with a combination in my nginx configuration. we need to set expire for objects in a specified location of nginx configuration to have expire at every 2 hours and also at 24hours. As of now the configuration looks as follows,

location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires 2h;
add_header Cache-Control public;
}

Is it possible to have expires for 2 timings like expires 2h | @24h; . Using | doesnt seems to be working. Is it possible to achieve the same with max age ? I would appreciate any help on the same.

The version and module status is as follows.
root@ip-mymachine# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.6
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --add-module=/opt/nginxmodules/headers-more-nginx-module-0.28 --add-module=/opt/nginxmodules/ngx_http_substitutions_filter_module --add-module=/opt/nginxmodules/ngx_pagespeed-release-1.9.32.10-beta --with-http_ssl_module
root@ip-mymachine#

Thanks
RGR

Dynamic folder passwords (no replies)

$
0
0
Hey there

Does anyone have any suggestions how to do dynamic folder based authentication (folders created & passwords set by python script)? usually we would use directory level htpasswd/htaccess but not possible with nginx (AFAIK)? we could rewrite/reload the nginx conf each time but it seems risky and overkill?

cheers

Having trouble getting Mediawiki behind Nginx (no replies)

$
0
0
I'm trying to setup Mediawiki behind Nginx with PHP-FPM. I found an old config that the Nginx wiki used to use? I get a 403 when accessing wiki.example.com, and a blank page when accessing index.php, test.php (a file I made with phpinfo() to test) and non-existent pages.

I've attached my configuration file and the output of /var/log/nginx/access.log

The environment is a fresh CentOS 7 box with the EPEL-release version of Nginx, SELinux is disabled. I have Mediawiki symlinked into the root of /var/www/wiki.example.com/public_html/mediawiki/

Nginx cache 1 KEY into multiple cache files (cache not running) (7 replies)

$
0
0
Hello all!

First, the specs:
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --with-http_flv_module --with-ipv6 --with-http_mp4_module --with-pcre=/usr/local/src/publicnginx/pcre-8.35 --sbin-path=/usr/local/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_realip_module --with-http_ssl_module --http-client-body-temp-path=/tmp/nginx_client --http-proxy-temp-path=/tmp/nginx_proxy --http-fastcgi-temp-path=/tmp/nginx_fastcgi --with-http_stub_status_module --add-module=/usr/local/src/publicnginx/ngx_cache_purge --with-threads

(everything as usual, but --with-threads)

The problem here: if people asks nginx for the same request_uri, it will create multiple files!! this way, the cache is not running ok...

You can see with this terminal output:

root@hyperserver [/var/nginx.cache/xxxxx]# find -type f -exec grep -a "KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c" {} \;
KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c
KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c
KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c
KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c
KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c

root@hyperserver [/var/nginx.cache/xxxxx]# find -type f -exec grep -la "KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c" {} \;
./7/b2/11b565d1eec91c3b1c45b95b26d8fb27
./7/f6/724563e7ef37e878a929ba2b112b8f67
./a/4d/4a55e3ebe2d00f8fe3dad638b5fbc4da
./e/1d/5cbad6ee61ad0025139302e63ae171de
./3/30/262bab653c221f922694982aef6e2303
./c/85/2163f57c0724f7b753884658ac98385c
./2/66/7c2ddb49631a53a4bdc8f599f8cc9662

root@hyperserver [/var/nginx.cache/xxxxx]# echo -n "/wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c" | md5sum
2163f57c0724f7b753884658ac98385c -

root@hyperserver [/var/nginx.cache/xxxxx]# find -type f -exec grep -la "KEY: /wp-content/themes/sahifa/timthumb.php?src=/wp-content/uploads/2015/11/Amir.jpg&h=50&w=50&a=c" {} \;
./7/b2/11b565d1eec91c3b1c45b95b26d8fb27
./7/f6/724563e7ef37e878a929ba2b112b8f67
./a/4d/4a55e3ebe2d00f8fe3dad638b5fbc4da
./e/1d/5cbad6ee61ad0025139302e63ae171de
./3/30/262bab653c221f922694982aef6e2303
./3/17/5869a50ae737e3985a0052634f44c173
./c/85/2163f57c0724f7b753884658ac98385c
./2/66/7c2ddb49631a53a4bdc8f599f8cc9662

As you see, for the same KEY, nginx is creating multiple files, one of them with the common "md5sum" path/name, the rest could not understand what calculation is done to name them....

The config is usual also:

proxy_cache_path /var/nginx.cache/xxxxx levels=1:2 keys_zone=xxxxx:3m max_size=4G inactive=90d;

and...

location ^~ /wp-content/themes/sahifa/timthumb.php {
expires 90d;
proxy_pass http://sharedip;
include proxy.inc;
proxy_cache xxxxx;
proxy_cache_key $cache_uri;
proxy_cache_valid 200 90d;
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_504 http_404;
}

my proxy server (apache) is all time proccessing the same php codes...

Somebody could give me a clue about what is happening here??? What could I do?

Thanks.

https redirect fromm root domain to www subdomain error (no replies)

$
0
0
Hello all,

I am facing this issue with https, so i'll get right to it. I have done days of googling and nothing has worked for me, I am running the latest stable release of nginx and have my domain example.com. When i visit my site this is what happens:

I go to example.com -> redirects to https://example.com - I get the message from chrome saying "your connection is not private"
i go to www.example.com -> redirects to https://www.example.com - all good
i go to http://example.com -> redirects to https://example.com - I get the message from chrome saying "your connection is not private"
i go to http://www.example.com -> redirect to https://www.example.com - all good
i go to https://example.com -> doesnt redirect - I get the message from chrome saying "your connection is not private"
i go to https://www.example.com -> works, all good

my certificate is for "www.example.com" and I would like it to redirect to https://www.example.com no matter what the visitor types. Any help is appreciated.

redirect / proxy_pass with nginx (1 reply)

$
0
0
hi forum,

i'm pretty new to nginx and trying to realize some redirects / proxy passes with it.
the goal is to redirect to different jettys running on different ports on the same server based on the URI. also i need to differ between certificates based on the domain which is used.

the first redirect (/rewrite/here/) and the differentiation between the differend domains works well. but i'm running into trouble for the second pass (/some/location).

the jetty behind the first rewrite is accessible on https://localhost:9443/rewrite/here/ . but the second one is listening directly on https://localhost:8443. so i need to pass https://domain/some/location to https://localhost:8443. it works basically but i end up in a loop while trying to login into the service on the second jetty.

i already tried different settings for the second redirect section but never got it working properly.

thanks in advance!

(nginx.conf attached)

Nginx - When I run a php I get a 404 error or no input file message (no replies)

$
0
0
I have installed a prestashop in multisite with a server nginx and php-fpm.

With this configuration I can acess web correctly but not to an specific php because I get a 404 error or file no input file message.

I can access to https://domain.es/es/ and to https://domain.es/es/index.php?controller=order but I can't access to https://domain.es/web/modules/paypal/express_checkout/payment.php.

---------------
server {

listen *:80;

listen *:443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /var/www/clients/client1/web1/ssl/domain.es.crt;
ssl_certificate_key /var/www/clients/client1/web1/ssl/domain.es.key;

server_name domain.es;

root /var/www/domain.es/web;

index index.html index.htm index.php index.cgi index.pl index.xhtml;

error_log /var/log/ispconfig/httpd/domain.es/error.log;
access_log /var/log/ispconfig/httpd/domain.es/access.log combined;

location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location /stats/ {

index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client1/web1/web/stats/.htpasswd_stats;
}

location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}

location ~ \.php$ {
try_files /99c11adf1b3f5ca126cf97d4559c1b8f.htm @php;
}
location @php {
# try_files $uri $uri/ /index.php?$args;
# try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_intercept_errors on;
}

location / {
index /index.php;
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
try_files $uri $uri/ /index.php?$args;
}

}
---------------

If I change the settings for the next one, I can acces at website, but on the login page I have not found error. And the other php script it works.

I can't access to https://domain.es/es/index.php?controller=order but I can access to https://domain.es/es/ by writeing index.php and to https://domain.es/web/modules/paypal/express_checkout/payment.php.

----------------
location @php {
# try_files $uri $uri/ /index.php?$args;
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
-----------------

What have I change so I can access to site without this php problems? Have I create a new location or something?

------------------
location @test {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
location /modules/paypal/express_checkout/payment.php {
try_files /99c11adf1b3f5ca126cf97d4559c1b8f.htm @test;
}
------------------

Tanks!

Primary domain rewrite for nginx works fine, but doesn't direct single pages (no replies)

$
0
0
We just moved our website to a new domain, and the new website uses a totally different URL structure for all of the pages on the website.

For example, the old URL might look like: http://example.com/product/product-name/

The new URL would look like this: http://www.example2.com/product-p/product-name/pro.htm

Here's a snippet showing an example of what I'm working with:

------------------------------------------------------------------------------------

server{

location /product/product-name/ {
rewrite ^/product/product-name/
http://www.example2.com/product-p/product-name/pro.htm
permanent;
}

server_name example.com www.example.com;
rewrite ^ $scheme://www.example2.com;

}

------------------------------------------------------------------------------------


As it's working now, http://www.example.com redirects to http://www.example2.com just fine.

However, if you try to visit http://www.example.com/product/product-name/ it doesn't redirect to http://www.example2.com/product-p/product-name/pro.htm, it simply redirects to the root domain http://www.example2.com

Does anyone know how we redirect the primary domain AND redirect single pages to their new page?

Thanks.

Rewrite 404 in subdir to parent dir (no replies)

$
0
0
Hi,

The expected behaviour I'm looking for is the following examples

www.test.co.uk/category/product404page > www.test.co.uk/category/
www.test.co.uk/anothercategory/morecategories/product404page > www.test.co.uk/anothercategory/morecategories/

So something like the the following is required

location ^~ /dynamicrecursivedir/ {
try_files $uri ../;
}

Is this possible?

How to compile Nginx from source (3 replies)

$
0
0
Hi all,
I'm Nginx newbie, I read Beginer & Wiki Guide and I want to compile Nginx from source. My Nginx server will work as Web server + Caching + Reverse Proxy (load balancing) , my server Centos 6.4 64 bit.
I downloaded Nginx 1.8.0 from here : http://nginx.org/download/nginx-1.8.0.tar.gz , then I compiled it with option:
<code>
./configure --prefix=/opt/nginx --sbin-path=/opt/nginx/sbin --conf-path=/opt/nginx/conf/ --user=nginx --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --http-log-path=/var/log/nginx/access.log --group=nginx --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
make
make install
</code>
Nginx was compiled successfully but:
- file "proxy_params" wasn't created
- Nginx cannot understand parameters : ip_hash , max_conns
So I get error when I try to start Nginx:
- [emerg] open() "/opt/nginx/conf/proxy_params" failed (2: No such file or directory) in /opt/nginx/site-enabled/proxy.conf:8
- [emerg] invalid number of arguments in "ip_hash" directive in /opt/nginx/site-enabled/upstreams.conf:5
- [emerg] invalid parameter "max_conns=1024" in /opt/nginx/site-enabled/upstreams.conf:5
This is my proxy.conf and upstreams.conf :
<code>
#proxy.conf
server {
listen 80 default_server;
server_name http-website.com;
server {
listen 80;
server_name https-website.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name staging.mymall.vn;
location / {
proxy_pass http://http;
}
location /static {
proxy_pass http://static;
}
</code>
<code>
#upstreams.conf
upstream http {
server 192.168.200.14:82 max_fails=3 fail_timeout=30s max_conns=1024;
zone http 256k;
keepalive 100;
queue 1024 [timeout=15];
}
upstream static {
ip_hash
server 192.168.200.14:83 max_fails=3 fail_timeout=30s max_conns=1024;
zone http 256k;
keepalive 100;
queue 1024 [timeout=15];
}
</code>
If I exclude proxy.conf and upstreams.conf , Nginx can work as Web server properly.
Please give me some advice, how should I compile Nginx to archive my purpose ?
Thanks in advance.

need help with unknown directive error (no replies)

$
0
0
I'm currently getting the following error with nginx:

$ sudo nginx -t
nginx: [emerg] unknown directive "sd#" in /etc/nginx/sites-enabled/default.save:27
nginx: configuration file /etc/nginx/nginx.conf test failed

As a result none of my reverse proxies work anymore. Anyone an idea what's causing this and how I can fix it?

For the record: I made a small change in the config (copy pasted code some code in), but reverted back again after I got the error. At the time my reverse proxies where still functioning, but after a server reboot they all stopped functioning (which makes sense).

Any help would be great, thanks!
Viewing all 2931 articles
Browse latest View live