Tag Archives: nginx

[Solved] Error during WebSocket handshake Unexpected response code 404

Problem Description: the websocket project was well deployed before. When it was transplanted to the domain name specified by the government cloud SLB, an error occurred:
error during websocket handshake unexpected response code 404

Solution

1. Configure nginx

In any case, configure nginx:
proxy_http_version 1.1;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;

location /xxx{
    proxy_pass http://127.0.0.1:7071/xxx;
    proxy_redirect    off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_set_header Connection "upgrade";
    proxy_set_header Upgrade $http_upgrade;
    
    proxy_connect_timeout 60s;
    proxy_read_timeout 7200s;
    proxy_send_timeout 600s;
    
    # 再不行的话就把下面的设置试一下
    #proxy_set_header Upgrade websocket;
    #proxy_pass_request_headers on;
    #access_log off;
    #proxy_buffering off;
    
}

2. Websocket configuration

We use springboot, and all configurations cannot be less

import com.fh.websocket.session.MySpringConfigurator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * enable WebSocket support
 */
@Configuration
public class WebSocketConfig {

	@Bean
	public ServerEndpointExporter serverEndpointExporter() {
		return new ServerEndpointExporter();
	}

	@Bean
	public MySpringConfigurator mySpringConfigurator() {
		return new MySpringConfigurator();
	}
}

3. Websocketserver needs to add a parameterless constructor

This is a pit, and it is normal to deploy to another
transplanting will not work in the past.

[Solved] Browser Access Error: Request Header or Cookie too large

Browser access page error

Error details

Possible causes:

The request header is too large, which is usually caused by writing a large value in the cookie. Access too frequently, the browser cache is too large, resulting in errors.

Solution:

The client can clean up the cookie cache
the server adjusts the size of nginx buffer and adds two lines

http
{
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;  
......
}

Restart service

[Solved] ClientAbortException: java.io.IOException: Connection reset by peer

Error message:

org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peer
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)
	at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:783)
	at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:688)
	at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:388)
	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:366)
	at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96)
	at org.springframework.util.StreamUtils$NonClosingOutputStream.write(StreamUtils.java:287)
	at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2177)
	at com.fasterxml.jackson.core.json.UTF8JsonGenerator._writeStringSegments(UTF8JsonGenerator.java:1319)
	at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeString(UTF8JsonGenerator.java:517)
	at com.fasterxml.jackson.databind.ser.std.StringSerializer.serialize(StringSerializer.java:41)
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:808)
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithoutTypeInfo(MapSerializer.java:764)
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:720)
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:35)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145)
	at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107)
	at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1514)
	at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:454)
	at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:104)
	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:290)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:183)
	at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:135)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at cn.aidcloud.base.xss.XssFilter.doFilter(XssFilter.java:58)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
	Suppressed: org.apache.catalina.connector.ClientAbortException: java.io.IOException: 断开的管道
		at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)
		at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:783)
		at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:688)
		at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:388)
		at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:366)
		at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96)
		at org.springframework.util.StreamUtils$NonClosingOutputStream.write(StreamUtils.java:287)
		at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2177)
		at com.fasterxml.jackson.core.json.UTF8JsonGenerator.close(UTF8JsonGenerator.java:1220)
		at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:458)
		... 69 common frames omitted
	Caused by: java.io.IOException:
		at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
		at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
		at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
		at sun.nio.ch.IOUtil.write(IOUtil.java:65)
		at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:469)
		at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:135)
		at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1363)
		at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:766)
		at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:586)
		at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:530)
		at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:547)
		at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84)
		at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:194)
		at org.apache.coyote.Response.doWrite(Response.java:615)
		at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:340)
		... 78 common frames omitted
Caused by: java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
	at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
	at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
	at sun.nio.ch.IOUtil.write(IOUtil.java:65)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:469)
	at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:135)
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1363)
	at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:766)
	at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:586)
	at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:530)
	at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:547)
	at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84)
	at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:194)
	at org.apache.coyote.Response.doWrite(Response.java:615)
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:340)
	... 103 common frames omitted

Corresponding front-end error net:: err_INCOMPLETE_CHUNKED_ENCODING 200

How to Solve:

After ES re extracts the data, the data of one field becomes particularly large, resulting in a particularly large package when returning to the front end, resulting in too large response data of nginx. Temporary files will be used for processing, but the user does not have the permission to operate this directory, so the service is stopped directly. Finally throw the above error.

Solution:

1. Check the error log of nginx (/data/000x/nginx/logs/error.Log)

2021/12/01 12:05:40 [crit] 66289#0: *680 open() "/data/000x/nginx/proxy_temp/2/02/0000000022" failed (13: Permission denied) while reading upstream, client: 192.16.199.1, server: localhost, request: "POST /api/search/result HTTP/1.1", upstream: "http://127.0.0.1:17803/search/result", host: "192.16.199.20:17002", referrer: "http://192.16.199.20:17002/pc/"

2. To/data/000x/nginx/proxy_Temp grant permission

Done!!!

[Solved] Nginx Certificate Fill Path Error: SSL: error:0200107B:system library:fopen:Unknown error:fopen

When nginx configures the SSL certificate, it starts with an error. The certificate file cannot be found. The error log is as follows:

2021/11/24 15:52:19 [emerg] 4124#3800: cannot load certificate "E:
ginx-1.21.4\ssl\6667030_xxxx.pem": BIO_new_file() failed (SSL: error:0200107B:system library:fopen:Unknown error:fopen('E:
ginx-1.21.4\ssl\6667030_xxxxxx.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
2021/11/24 15:53:33 [emerg] 1832#4972: cannot load certificate "E:
ginx-1.21.4\ssl\6667030_xxxx.pem": BIO_new_file() failed (SSL: error:0200107B:system library:fopen:Unknown error:fopen('E:
ginx-1.21.4\ssl\6667030_xxxx.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)

Solution:

Change the address path of disk e to “\\”, which was written as “ssl_certificate”       E: “\nginx-1.21.4\SSL\6667030_xxxx.PEM”, it keeps reporting errors

 server {
        listen       443 ssl;
        server_name  xxxx;

        ssl_certificate      E:\\nginx-1.21.4\ssl\6667030_xxxx.pem;
        ssl_certificate_key  E:\\nginx-1.21.4\ssl\6667030_xxxx.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;


		location /api/ {
			client_max_body_size 1000m;
			alias   E:\dev\Server\api/;
            index  index.html index.htm;
        }
		
    }

net::ERR_HTTP2_PROTOCOL_ERROR 200 [How to Solve]

Scenario:

In the web environment, a request reports this problem, but other requests are normal. Open the F12 console and see the exception net:: err_HTTP2_PROTOCOL_Error 200 error

Troubleshooting:

Viewing the error.log report of nginx is that the permission of a temporary file is insufficient. The reason is that the account for starting nginx does not have operation permission in the previously reported directory

Solution:

1. Open the corresponding temporary directory to read and write permissions

2. Start nginx with the root account

[Solved] Git push error: error: RPC failed; HTTP 413 curl 22 the requested URL returned error: 413

 

#Accident scene

Git submitted push with enrollment error:

Enumerating objects: 448, done.
Delta compression using up to 4 threads
Total 424 (delta 109), reused 0 (delta 0), pack-reused 0
POST git-receive-pack (433422517 bytes)
Error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413

#Solution

As can be seen from the above error message, the code size submitted by Git is 433422517 bytes, about 400m; It is suspected that the submitted documents are too large.

1. First, modify the GIT global configuration

git config –global http.postBuffer 524288000

The result is pushed again, which is invalid
it is suspected that the size of the transfer file is limited in other places. In retrospect, the server where Git is located was accessed directly, but later it was accessed after being forwarded by Nginx. Therefore, I think there may be a problem with the Nginx configuration.

2. View git related configuration of Nginx

	location ~ /git(/.*) {
	    # others
	    
	    client_max_body_size 200M;
	}

The client_max_body_Size modify the configuration to 500m and restart Nginx
push again to solve the problem.

After configuring the ES password, logstash starts with error 401?

This problem occurs because after elasticsearch configures the password, the connection es encounters authentication problems when logstash starts. The solution requires configuring the account password in the logstash configuration file

vim /app/logstash/config/beat_es.conf

input {
   beats {
     port => 5044
   }
}
filter {
    #Only do json parsing on nginx json logs, system messages are in other formats, no need to handle
    if [fields][log_type] == "nginx"{
      json {
         source => "message"
         remove_field => ["beat","offset","tags","prospector"] #Remove fields, no collection required
      }
      date {
        match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"] # match the timestamp field
        target => "@timestamp" # write the matched data to the @timestamp field
      }
  }
}
 
output {

       if [fields][log_type] == "ruoyi" {
         elasticsearch {
            hosts => ["node1:9200","node2:9200"]
            user => elastic
            password => "123123"
            index => "ruoyi_log"
            timeout => 300
        }
       }
}

Vue agent reports an Error 404 nginx configuration method

The error points are different and the solutions are different. Use them after understanding

Recently, I was working on a personal blog. There was a music box function that called the API of Netease cloud music.

Agent configured in Vue

There is no problem with the local NPM run serve

But after packing in nginx

The API of the agent will report 404

  terms of settlement:

Configuration in nginx.config

location /music/ {
        proxy_pass http://39.108.136.207:3000/;
        
	   }

  Pit point:

        proxy_ Pass cannot be placed directly on the IP + port

        Additional and/or corresponding methods are required

        

PHP large file upload error 413: request entity too large [How to Solve]

1. Nginx configuration modification

1. Modify the Nginx.conf (/ etc/Nginx/Nginx.conf) configuration file, and add or modify the following configuration in http{}:

client_max_body_size 20m; 

2. Restart nginx

systemctl restart nginx

2. PHP configuration modification

Find the location of the php.ini file:

Method 1

Use the command whereis php; to view the php related directories, if you can't find the ini file in the listed directories, you can refer to method 2.

Method 2

php --info > a.log;
vim a.log, To view the output, you can directly search for php.ini and you will see the directory where the file is located. As the following screenshot.

1. Modify the php.ini (/etc/PHP.ini) configuration file, find the following configuration and modify it:

post_max_size = 20M  
upload_max_filesize = 20M  

2. Restart PHP FPM

systemctl restart php-fpm

Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:

Error reporting reason:

NGX is not installed_http_ssl_Module module

Solution:

    1. check which modules are installed in Nginx
/usr/local/ngxin/sbin/nginx -V

nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
configure arguments:

No parameters after configure arguments indicates that no modules are installed
install NGX_http_ssl_Module the module is in the installation directory ofngxin, note the installation directory, find configure and execute:

./configure --prefix=/usr/local/nginx 
./configure --with-http_ssl_module

After installation, execute make and make install

make
...
make install

Back up the original nginx, and overwrite the compiled nginx with the original nginx

cp /usr/local/nginx/sbin/nginx  /usr/local/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/nginx/sbin/

Check whether the installation is successful

/usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_ssl_module

[UNK] enable nginx

/usr/local/nginx/sbin/nginx -s reload

Error 0 when adding SSL access to laravel project

Problem Description: project development framework DCAT, server management tool pagoda, configure SSL. Log in and report error 0. Check the nginx error log and find that it is not written. When the browser opens the debugging function, the console reports an error fastcgi send in stderr: “PHP message: PHP fatal error: allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in, the configuration file. Env configuration HTTPS and JS base file HTTPS have been changed.

Solution:
find config/admin.php and change the HTTPS configuration item to true