Xefee Hosting
My location:Xefee Hosting » Web Hosting » Detail

converted to nginx apache Some attention points

From:HostingBig Middle Small】 Views:66 Time(s)

The whole station recently upgraded from apache to nginx, customer site, about 30 servers most of the structure of bit tomcat + apache, there is only one php page
I look to upgrade the attention of a few problems of point

1.
When we go to access a directory on the server, he does not automatically add a /, change the browser will give an error page can not be opened, this time the browser to fetch the address is actually written in the address and the upstream upstream port, or if not used to do when when using the localhost servername when the browser to visit http://127.0.0.1/dir.
Solution
In the definition of each virtual server host add
if (-d $ request_filename) (
   rewrite ^/(.*)([^/])$ http:// $ host / $ 1 $ 2 / permanent;
)
Note that the definition of root field must also appear in the server if the server is not defined in the root existence of errors will
Examples:
server (
listen 800;
server_name www.1.com;
root / opt/1-index; / / here defines the time of the visit will be added in the directory / If not defined here, the above still does not force url rewriting
include vhost / alias.conf;
include vhost / proxy.conf;
if (-d $ request_filename) (
   rewrite ^/(.*)([^/])$ http:// $ host / $ 1 $ 2 / permanent;
)
error_page 405 = 200 @ 405;
location @ 405 (
proxy_pass http://PROXY_STATIC;
)
location / (
root / opt/1-index; / / only in the definition is of no use here, and here you can not do even the definition of
rewrite ^ / (\ d +) \. home $ / index.html? userId = $ 1 last;
index index.html index.htm;
)

2.url rewrite the attention of:
Support the original url is the url rewriting does not support regular
rewrite ^ / (\ d +) \. home $ / index.html? userId = $ 1 last;
The rewrite of ^ / (\ d +) \. Home $ this part of the support for regular
The / index.html? UserId = $ 1
Do not use regular not match the regular / index.html? * UserId = $ 1 and he will go. Html? * UserId = $ 1 this url and then give you a 404 not found

3.post way to access a static file
Apache, IIS, Nginx etc. Most web servers do not allow a static file response to POST request, otherwise it will return "HTTP/1.1 405 Method not allowed" error. (But before the program run on no problem in apache)
If there is such demand for it to do the following configuration of the
error_page 405 = 200 @ 405;
location @ 405 (
proxy_pass http://PROXY_STATIC;
# Root / usr / local / nginx / html;
)
Redirect all 405 errors and then it all into a 200 Bad Request 405 to an agent to perform all
Or write the local path, because my path more so redirect the request to a web server on the

4.. About Anti-Daolian
1.com demand is coming not from the original request to the addition of a 403
Because in the virtual host in configure no effect may be that we are using a virtual directory of the reasons
Therefore, we done directly on the directory prevent Daolian
In the alias in
Alias Configuration
location / res / (
                alias / opt / Src /;
                valid_referers none blocked server_names *. 1.com;
                if ($ invalid_referer) (
return 403;
                )
        )

5, forwarding the request on the dynamic
location ~ ^ / login / (.* \. do) $ (
                proxy_pass http://login;
proxy_set_header X-Real-IP $ remote_addr;
)
 ~ ^ / Login / (.* \. Do) $ this that all matches / login / under. Do's are forwarded to an upstream pond treatment here does not play much role in the $ symbol as long as it is. Do all his will turn not to. do before the end of transfer

6. On the php upload file size problem
Only change in the configuration of php is useless
Where there is need to change the configuration of nginx

client_max_body_size 10M;
His default is 1M;

Note that the above is the basic point
Please sign that when you have a copy:
Xefee hosting<<converted to nginx apache Some attention points>>:http://www.xefee.com/article-1322-1.html
Tags: Editor By:luis
Next Article:Web Hosting Knowledge Base
New
Sponsored links

Advertisement - Links - Maps - RSS - Contact us - Copyright