: This article mainly introduces the configuration of nginx for https. if you are interested in the PHP Tutorial, refer to it.
Server {listen 443; server_name www.roamwifi.net; # configure the publishing directory as/usr/local/nginx/data/rw-owsroot/usr/local/nginx/data/rw-ows; ssl on; ssl_certificate server. pem; ssl_certificate_key server. key; ssl_session_timeout 5 m; ssl_protocols SSLv3 TLSv1; ssl_ciphers HIGH :! ADH :! EXPORT56: RC4 + RSA: + MEDIUM; login on; # add the following code: error_page 405 = 405 $ uri; location/{proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_pass http://rw-ows ; #======================================= CORS nginx configuration ================ ========================== if ($ http_origin ~ * (Https?: // [^/] * \. Roamwifi \. net (: [0-9] + )?) $) {Set $ cors "true";} if ($ request_method = 'options') {set $ cors "$ {cors} OPTIONS ";} if ($ request_method = 'get') {set $ cors "$ {cors} GET";} if ($ request_method = 'post ') {set $ cors "$ {cors} post";} if ($ cors = "trueget") {add_header 'access-Control-Allow-origin' "$ http_origin "; add_header 'access-Control-Allow-Credentials ''true';} if ($ cors = "truepost") {add_header 'access-Control-Allo W-Origin '"$ http_origin"; add_header 'access-Control-Allow-Credentials' 'true';} if ($ cors = "trueoptions ") {# add_header 'access-Control-Allow-origin' "$ http_origin"; add_header 'access-Control-Allow-origin ''*'; add_header 'access-Control-Allow-Credentials ''true'; add_header 'access-Control-Max-Age' 1728000; add_header 'access-Control-Allow-headers' 'authorization, content-Type, Accept, Origin, U Ser-Agent, DNT, Cache-Control, X-Mx-ReqToken, Keep-Alive, X-Requested-With, If-Modified-Since '; add_header 'content-length' 0; add_header 'content-type' 'text/plain charset = UTF-8 '; # return 204; return 200 ;}} location ~. * \. (Jsp | do )? $ {Proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_pass http://rw-ows ;} Location ~. *\. (Html | gif | jpg | jpeg | bmp | png | ico | txt | js | css) $ {root/usr/local/nginx/data/rw-ows; expires 1d ;}}
The above describes the nginx configuration for https, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.