Nginx-Small white application of SSL, swollen and combined with PHP program to use

Source: Internet
Author: User
Tags startssl
Because the site needs to use HTTPS to register the user
Small white from the STARTSSL application to the certificate, do not know the swelling and PHP program combined to use
First of all, the operation of the small white Program environment, hope to get help from everyone
1) Nginx Agent network Apache working method processing PHP Script
2) The website program uses MVC mode 3) is also very difficult to configure the Nginx virtual host
(There are only 2 virtual host profiles, domain.conf and ssl.domain.conf)
Small white paste out configuration, do not know whether the configuration is correct
The domain.conf is configured 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 a file that is configured with HTTPS

server {    listen 443;    server_name ssl.domain.cn;    root 这里的路径跟domain.conf里的路径一致;    index index.php;    ssl on;    ssl_certificate ssl.crt;    ssl_certificate_key ssl.key;    location ~ .(php|phtml)?$ {        proxy_pass http://apache;    }}

The configuration can also work, if you can combine the 2 configuration files into one.
Well, let's say that the function to be implemented is like this.
1) User Click to register http://domain.cn/signin
It will automatically switch to Https://domain.cn/signin.
Jump action is the program to control, or in the Nginx configuration file control it
2) using HTTPS to open the Web page, the page css,js are not working properly, the page can not render the style
The above is the small white in the configuration of SSL, increase the HTTPS function encountered problems, hoping to get the help of the great God
If the great God passing, have time, also willing to share experience, the world's small white are most willing to see, haha

Reply content:

Because the site needs to use HTTPS to register the user
Small white from the STARTSSL application to the certificate, do not know the swelling and PHP program combined to use
First of all, the operation of the small white Program environment, hope to get help from everyone
1) Nginx Agent network Apache working method processing PHP Script
2) The website program uses MVC mode 3) is also very difficult to configure the Nginx virtual host
(There are only 2 virtual host profiles, domain.conf and ssl.domain.conf)
Small white paste out configuration, do not know whether the configuration is correct
The domain.conf is configured 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 a file that is configured with HTTPS

server {    listen 443;    server_name ssl.domain.cn;    root 这里的路径跟domain.conf里的路径一致;    index index.php;    ssl on;    ssl_certificate ssl.crt;    ssl_certificate_key ssl.key;    location ~ .(php|phtml)?$ {        proxy_pass http://apache;    }}

The configuration can also work, if you can combine the 2 configuration files into one.
Well, let's say that the function to be implemented is like this.
1) User Click to register http://domain.cn/signin
It will automatically switch to Https://domain.cn/signin.
Jump action is the program to control, or in the Nginx configuration file control it
2) using HTTPS to open the Web page, the page css,js are not working properly, the page can not render the style
The above is the small white in the configuration of SSL, increase the HTTPS function encountered problems, hoping to get the help of the great God
If the great God passing, have time, also willing to share experience, the world's small 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:

#监听SSL的端口listen 443;#打开SSL并指定证书ssl on;ssl_certificate ssl.crt;ssl_certificate_key ssl.key;

Yes, it doesn't matter what the other settings are.

If not, go and see the Nginx log.

For merging two configuration files, see this answer:
http://segmentfault.com/q/1010000000128892

The suggestion about jump logic: suggest that the website program write the domain name unrelated, in the program with similar/user.php such a relative address to jump, and then in Nginx to do from http to https jump.
But as a result, you still need to write two servers, and in the 80 server, jump to the HTTPS protocol:

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 the HTTPS protocol, loading resources from the HTTP protocol (CSS/JS) will have a warning, it is not possible for all users to ignore the warning, so you need to let all resources are transmitted over HTTPS.

If I remember right. Can do this

listen 80;listen 443;

Your 443 interface is just for php|phtml no support for CSS and JS files. So I can't use it.

Location ~. . (gif|jpg|jpeg|png|bmp|swf) $ {expires 1d; (js|css|html|htm) $ {expires 12h; 23}

Join the above to see

  • 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.