Nginx-ssl applied for by Tom. How can it be used with PHP programs?

Source: Internet
Author: User
Tags startssl
Because the site needs to Use https to register the certificate that the user has applied for from startssl, I don't know if it is swollen and the php program is used together. Let's talk about the running environment of the applet first, hope to get help from everyone. 1) nginx proxy Intranet apache working method to handle PHP scripts 2 )... because the site needs to Use https for user registration
I don't know how to use the certificate I applied for from startssl with php programs.
Let's talk about the running environment of the little white program first, hoping to get help from everyone.
1) nginx proxy Intranet apache working method to process PHP scripts
2) website programs use the MVC method. 3) it is also very difficult to configure the nginx virtual host.
(There are only two VM configuration files, domain. conf and ssl. domain. conf)
I am not sure whether the configuration is correct.
The configuration of domain. conf is as follows:

server {    listen 80 default;    server_name www.domain.cn;    root /path/public;    index index.php;    location ~ .(php|phtml)?$ {        proxy_pass http://apache;    }    include proxy.conf;}

The other is an https configuration file.

Server {listen 443; server_name ssl.domain.cn; root the path here is the same as domain. the path in conf is consistent; index. php; ssl on; ssl_certificate ssl. crt; ssl_certificate_key ssl. key; location ~ . (Php | phtml )? $ {Proxy_pass http: // apache ;}}

Configuration can also be completed. It would be nice to merge the two configuration files into one.
Okay, let's talk about the functionality we want to implement.
1) User click to register http://domain.cn/signin
It is automatically converted to https://domain.cn/signin
Is the jump action controlled by a program or in the nginx configuration file?
2) When You Use https to open a webpage, the css and js of the webpage cannot work normally, and the page cannot render this style.
The above is the problem that Tom encountered when configuring ssl and adding https functions, hoping to get help from others.
If the great God passes by, has time, and is willing to share his experience, the world's little white are most willing to see, haha

Reply content:

Because the site needs to Use https for user registration
I don't know how to use the certificate I applied for from startssl with php programs.
Let's talk about the running environment of the little white program first, hoping to get help from everyone.
1) nginx proxy Intranet apache working method to process PHP scripts
2) website programs use the MVC method. 3) it is also very difficult to configure the nginx virtual host.
(There are only two VM configuration files, domain. conf and ssl. domain. conf)
I am not sure whether the configuration is correct.
The configuration of domain. conf is as follows:

server {    listen 80 default;    server_name www.domain.cn;    root /path/public;    index index.php;    location ~ .(php|phtml)?$ {        proxy_pass http://apache;    }    include proxy.conf;}

The other is an https configuration file.

Server {listen 443; server_name ssl.domain.cn; root the path here is the same as domain. the path in conf is consistent; index. php; ssl on; ssl_certificate ssl. crt; ssl_certificate_key ssl. key; location ~ . (Php | phtml )? $ {Proxy_pass http: // apache ;}}

Configuration can also be completed. It would be nice to merge the two configuration files into one.
Okay, let's talk about the functionality we want to implement.
1) User click to register http://domain.cn/signin
It is automatically converted to https://domain.cn/signin
Is the jump action controlled by a program or in the nginx configuration file?
2) When You Use https to open a webpage, the css and js of the webpage cannot work normally, and the page cannot render this style.
The above is the problem that Tom encountered when configuring ssl and adding https functions, hoping to get help from others.
If the great God passes by, has time, and is willing to share his experience, the world's little white are most willing to see, haha

This problem has nothing to do with PHP.

You only need to add the following code to the server segment:

# Listen to the SSL port listen 443; # Open SSL and specify the certificate ssl on; ssl_certificate ssl. crt; ssl_certificate_key ssl. key;

It does not matter with other settings.

If not, check the nginx log.

For how to merge the two configuration files, see the following answer:
Http://segmentfault.com/q/1010000000128892

Suggestion on the jump logic: It is recommended that the website program be written as a domain name irrelevant, in the program using a similar/user. php jump, and then jump from http to https in Nginx.
But in this case, you still need to write two servers to jump to the https protocol in the 80 server:

server {    listen 80;    server_name xxoo.com;    location / {        rewrite ^/(.*) https://xxoo.com/$1 permanent;    }}

The security policy of the new version of the browser determines that, in the https protocol, loading resources from the http protocol (CSS/JS) will have a warning, so it is impossible for all users to ignore the warning, therefore, you need to transmit all resources over https.

If yes. Yes.

listen 80;listen 443;

Your 443 interface is only for php | phtml and does not support CSS and JS files. So it cannot be used ~~ I think so.

18 location ~ .. (Gif | jpg | jpeg | png | bmp | swf) ${19 expires 1d; 20} 21 location ~ .. (Js | css | html | htm )? ${22 expires 12 h; 23}

Join the above to see

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.